mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
LED stream set to max 20hz
This commit is contained in:
parent
4c81614c69
commit
669501a084
@ -14,9 +14,9 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
// hyperion includes
|
// hyperion includes
|
||||||
@ -43,6 +43,7 @@ JsonProcessor::JsonProcessor(QString peerAddress, Logger* log, QObject* parent,
|
|||||||
, _imageProcessor(ImageProcessorFactory::getInstance().newImageProcessor())
|
, _imageProcessor(ImageProcessorFactory::getInstance().newImageProcessor())
|
||||||
, _streaming_logging_activated(false)
|
, _streaming_logging_activated(false)
|
||||||
, _image_stream_timeout(0)
|
, _image_stream_timeout(0)
|
||||||
|
, _led_stream_timeout(0)
|
||||||
{
|
{
|
||||||
// notify hyperion about a jsonMessageForward
|
// notify hyperion about a jsonMessageForward
|
||||||
connect(this, &JsonProcessor::forwardJsonMessage, _hyperion, &Hyperion::forwardJsonMessage);
|
connect(this, &JsonProcessor::forwardJsonMessage, _hyperion, &Hyperion::forwardJsonMessage);
|
||||||
@ -55,10 +56,8 @@ JsonProcessor::JsonProcessor(QString peerAddress, Logger* log, QObject* parent,
|
|||||||
connect(_hyperion, &Hyperion::sendServerInfo, this, &JsonProcessor::forceServerInfo);
|
connect(_hyperion, &Hyperion::sendServerInfo, this, &JsonProcessor::forceServerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// led color stream update timer
|
|
||||||
_timer_ledcolors.setSingleShot(false);
|
|
||||||
connect(&_timer_ledcolors, SIGNAL(timeout()), this, SLOT(streamLedcolorsUpdate()));
|
|
||||||
_image_stream_mutex.unlock();
|
_image_stream_mutex.unlock();
|
||||||
|
_led_stream_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonProcessor::handleMessage(const QString& messageString)
|
void JsonProcessor::handleMessage(const QString& messageString)
|
||||||
@ -980,11 +979,13 @@ void JsonProcessor::handleLedColorsCommand(const QJsonObject& message, const QSt
|
|||||||
_streaming_leds_reply["success"] = true;
|
_streaming_leds_reply["success"] = true;
|
||||||
_streaming_leds_reply["command"] = command+"-ledstream-update";
|
_streaming_leds_reply["command"] = command+"-ledstream-update";
|
||||||
_streaming_leds_reply["tan"] = tan;
|
_streaming_leds_reply["tan"] = tan;
|
||||||
_timer_ledcolors.start(125);
|
connect(_hyperion, &Hyperion::rawLedColors, this, &JsonProcessor::streamLedcolorsUpdate, Qt::UniqueConnection);
|
||||||
|
_ledcolorsLedsActive = true;
|
||||||
}
|
}
|
||||||
else if (subcommand == "ledstream-stop")
|
else if (subcommand == "ledstream-stop")
|
||||||
{
|
{
|
||||||
_timer_ledcolors.stop();
|
disconnect(_hyperion, &Hyperion::rawLedColors, this, &JsonProcessor::streamLedcolorsUpdate);
|
||||||
|
_ledcolorsLedsActive = false;
|
||||||
}
|
}
|
||||||
else if (subcommand == "imagestream-start")
|
else if (subcommand == "imagestream-start")
|
||||||
{
|
{
|
||||||
@ -1095,27 +1096,32 @@ void JsonProcessor::sendErrorReply(const QString &error, const QString &command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JsonProcessor::streamLedcolorsUpdate()
|
void JsonProcessor::streamLedcolorsUpdate(const std::vector<ColorRgb>& ledColors)
|
||||||
{
|
{
|
||||||
QJsonObject result;
|
if ( (_led_stream_timeout+50) < QDateTime::currentMSecsSinceEpoch() && _led_stream_mutex.tryLock(0) )
|
||||||
QJsonArray leds;
|
|
||||||
|
|
||||||
const PriorityMuxer::InputInfo & priorityInfo = _hyperion->getPriorityInfo(_hyperion->getCurrentPriority());
|
|
||||||
for(auto color = priorityInfo.ledColors.begin(); color != priorityInfo.ledColors.end(); ++color)
|
|
||||||
{
|
{
|
||||||
QJsonObject item;
|
_led_stream_timeout = QDateTime::currentMSecsSinceEpoch();
|
||||||
item["index"] = int(color - priorityInfo.ledColors.begin());
|
QJsonObject result;
|
||||||
item["red"] = color->red;
|
QJsonArray leds;
|
||||||
item["green"] = color->green;
|
|
||||||
item["blue"] = color->blue;
|
for(auto color = ledColors.begin(); color != ledColors.end(); ++color)
|
||||||
leds.append(item);
|
{
|
||||||
|
QJsonObject item;
|
||||||
|
item["index"] = int(color - ledColors.begin());
|
||||||
|
item["red"] = color->red;
|
||||||
|
item["green"] = color->green;
|
||||||
|
item["blue"] = color->blue;
|
||||||
|
leds.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
result["leds"] = leds;
|
||||||
|
_streaming_leds_reply["result"] = result;
|
||||||
|
|
||||||
|
// send the result
|
||||||
|
emit callbackMessage(_streaming_leds_reply);
|
||||||
|
|
||||||
|
_led_stream_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
result["leds"] = leds;
|
|
||||||
_streaming_leds_reply["result"] = result;
|
|
||||||
|
|
||||||
// send the result
|
|
||||||
emit callbackMessage(_streaming_leds_reply);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonProcessor::setImage(int priority, const Image<ColorRgb> & image, int duration_ms)
|
void JsonProcessor::setImage(int priority, const Image<ColorRgb> & image, int duration_ms)
|
||||||
|
Loading…
Reference in New Issue
Block a user