From a3b326a18d5390380ebb41c2518a3de1b570fcd3 Mon Sep 17 00:00:00 2001 From: Paulchen-Panther Date: Sun, 21 Jul 2019 19:06:47 +0200 Subject: [PATCH] trigger muxer on color changes Signed-off-by: Paulchen-Panther --- assets/webconfig/js/content_remote.js | 1 + include/hyperion/HyperionIManager.h | 2 +- include/hyperion/PriorityMuxer.h | 5 +++++ libsrc/api/JsonAPI.cpp | 30 ++++----------------------- libsrc/hyperion/Hyperion.cpp | 4 +++- libsrc/hyperion/HyperionIManager.cpp | 4 ++-- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/assets/webconfig/js/content_remote.js b/assets/webconfig/js/content_remote.js index 2138ce1b..4c874c61 100644 --- a/assets/webconfig/js/content_remote.js +++ b/assets/webconfig/js/content_remote.js @@ -300,6 +300,7 @@ $(document).ready(function() { rgb = rgbT; sendColor(); setStorage('rmcpcolor', hex); + updateInputSelect(); }); $("#reset_color").off().on("click", function(){ diff --git a/include/hyperion/HyperionIManager.h b/include/hyperion/HyperionIManager.h index 7d548359..0ce217c5 100644 --- a/include/hyperion/HyperionIManager.h +++ b/include/hyperion/HyperionIManager.h @@ -37,7 +37,7 @@ public: /// @param inst The instance to check /// @return True when running else false /// - const bool IsInstanceRunning(const quint8& inst) { return _runningInstances.contains(inst); }; + bool IsInstanceRunning(const quint8& inst) { return _runningInstances.contains(inst); }; /// /// @brief Get a Hyperion instance by index diff --git a/include/hyperion/PriorityMuxer.h b/include/hyperion/PriorityMuxer.h index 99f5d698..1ecadd2d 100644 --- a/include/hyperion/PriorityMuxer.h +++ b/include/hyperion/PriorityMuxer.h @@ -182,6 +182,11 @@ public: /// void clearAll(bool forceClearAll=false); + /// + /// @brief Queue a manual push where muxer doesn't recognize them (e.g. continous single color pushes) + /// + void queuePush(void){ emit timeRunner(); }; + signals: /// /// @brief Signal which emits when a effect or color with timeout > -1 is running, once per second diff --git a/libsrc/api/JsonAPI.cpp b/libsrc/api/JsonAPI.cpp index cea4f3a1..16d8ccf3 100644 --- a/libsrc/api/JsonAPI.cpp +++ b/libsrc/api/JsonAPI.cpp @@ -210,35 +210,13 @@ void JsonAPI::handleColorCommand(const QJsonObject& message, const QString& comm // extract parameters int priority = message["priority"].toInt(); int duration = message["duration"].toInt(-1); - QString origin = message["origin"].toString("Empty") + "@"+_peerAddress; + const QString origin = message["origin"].toString("Empty") + "@"+_peerAddress; - std::vector colorData(_hyperion->getLedCount()); const QJsonArray & jsonColor = message["color"].toArray(); - unsigned int i = 0; - for (; i < unsigned(jsonColor.size()/3) && i < _hyperion->getLedCount(); ++i) - { - colorData[i].red = uint8_t(jsonColor.at(3u*i).toInt()); - colorData[i].green = uint8_t(jsonColor.at(3u*i+1u).toInt()); - colorData[i].blue = uint8_t(jsonColor.at(3u*i+2u).toInt()); - } + const ColorRgb color = {uint8_t(jsonColor.at(0).toInt()),uint8_t(jsonColor.at(1).toInt()),uint8_t(jsonColor.at(2).toInt())}; - // copy full blocks of led colors - unsigned size = i; - while (i + size < _hyperion->getLedCount()) - { - memcpy(&(colorData[i]), colorData.data(), size * sizeof(ColorRgb)); - i += size; - } - - // copy remaining block of led colors - if (i < _hyperion->getLedCount()) - { - memcpy(&(colorData[i]), colorData.data(), (_hyperion->getLedCount()-i) * sizeof(ColorRgb)); - } - - // register and set color - _hyperion->registerInput(priority, hyperion::COMP_COLOR, origin); - _hyperion->setInput(priority, colorData, duration); + // set color + _hyperion->setColor(priority, color, duration, origin); // send reply sendSuccessReply(command, tan); diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 0d584c15..88a97f40 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -357,8 +357,10 @@ void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_m // register color registerInput(priority, hyperion::COMP_COLOR, origin); - // write color to muxer + // write color to muxer & queuePush setInput(priority, ledColors, timeout_ms); + if(timeout_ms <= 0) + _muxer.queuePush(); } const QStringList & Hyperion::getAdjustmentIds() const diff --git a/libsrc/hyperion/HyperionIManager.cpp b/libsrc/hyperion/HyperionIManager.cpp index b38e502d..306b3923 100644 --- a/libsrc/hyperion/HyperionIManager.cpp +++ b/libsrc/hyperion/HyperionIManager.cpp @@ -155,8 +155,8 @@ bool HyperionIManager::deleteInstance(const quint8& inst) if(!isInstAllowed(inst)) return false; - // stop it if required as blocking - stopInstance(inst, true); + // stop it if required as blocking and wait + if (stopInstance(inst, true)); if(_instanceTable->deleteInstance(inst)) {