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
@ -43,6 +43,7 @@ JsonProcessor::JsonProcessor(QString peerAddress, Logger* log, QObject* parent,
|
||||
, _imageProcessor(ImageProcessorFactory::getInstance().newImageProcessor())
|
||||
, _streaming_logging_activated(false)
|
||||
, _image_stream_timeout(0)
|
||||
, _led_stream_timeout(0)
|
||||
{
|
||||
// notify hyperion about a jsonMessageForward
|
||||
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);
|
||||
}
|
||||
|
||||
// led color stream update timer
|
||||
_timer_ledcolors.setSingleShot(false);
|
||||
connect(&_timer_ledcolors, SIGNAL(timeout()), this, SLOT(streamLedcolorsUpdate()));
|
||||
_image_stream_mutex.unlock();
|
||||
_led_stream_mutex.unlock();
|
||||
}
|
||||
|
||||
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["command"] = command+"-ledstream-update";
|
||||
_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")
|
||||
{
|
||||
_timer_ledcolors.stop();
|
||||
disconnect(_hyperion, &Hyperion::rawLedColors, this, &JsonProcessor::streamLedcolorsUpdate);
|
||||
_ledcolorsLedsActive = false;
|
||||
}
|
||||
else if (subcommand == "imagestream-start")
|
||||
{
|
||||
@ -1095,16 +1096,18 @@ void JsonProcessor::sendErrorReply(const QString &error, const QString &command,
|
||||
}
|
||||
|
||||
|
||||
void JsonProcessor::streamLedcolorsUpdate()
|
||||
void JsonProcessor::streamLedcolorsUpdate(const std::vector<ColorRgb>& ledColors)
|
||||
{
|
||||
if ( (_led_stream_timeout+50) < QDateTime::currentMSecsSinceEpoch() && _led_stream_mutex.tryLock(0) )
|
||||
{
|
||||
_led_stream_timeout = QDateTime::currentMSecsSinceEpoch();
|
||||
QJsonObject result;
|
||||
QJsonArray leds;
|
||||
|
||||
const PriorityMuxer::InputInfo & priorityInfo = _hyperion->getPriorityInfo(_hyperion->getCurrentPriority());
|
||||
for(auto color = priorityInfo.ledColors.begin(); color != priorityInfo.ledColors.end(); ++color)
|
||||
for(auto color = ledColors.begin(); color != ledColors.end(); ++color)
|
||||
{
|
||||
QJsonObject item;
|
||||
item["index"] = int(color - priorityInfo.ledColors.begin());
|
||||
item["index"] = int(color - ledColors.begin());
|
||||
item["red"] = color->red;
|
||||
item["green"] = color->green;
|
||||
item["blue"] = color->blue;
|
||||
@ -1116,6 +1119,9 @@ void JsonProcessor::streamLedcolorsUpdate()
|
||||
|
||||
// send the result
|
||||
emit callbackMessage(_streaming_leds_reply);
|
||||
|
||||
_led_stream_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void JsonProcessor::setImage(int priority, const Image<ColorRgb> & image, int duration_ms)
|
||||
|
Loading…
Reference in New Issue
Block a user