From a41051cc8432e3db8a4f172f31f6a4210b960bb4 Mon Sep 17 00:00:00 2001 From: redPanther Date: Thu, 26 May 2016 07:01:10 +0200 Subject: [PATCH 1/2] prevent colorsmoothing from flooding led device with data when no new input data is available (#654) resolve compiler warnings Former-commit-id: c7fbdce5dc7fde8b8e188320408dc547b9ad5e51 --- libsrc/hyperion/Hyperion.cpp | 6 +++--- libsrc/hyperion/LinearColorSmoothing.cpp | 11 ++++++++--- libsrc/hyperion/LinearColorSmoothing.h | 2 ++ libsrc/utils/RgbChannelCorrection.cpp | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 538772a9..9c871818 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -480,7 +480,7 @@ RgbChannelCorrection* Hyperion::createRgbChannelCorrection(const Json::Value& co RgbChannelAdjustment* Hyperion::createRgbChannelAdjustment(const Json::Value& colorConfig, const RgbChannel color) { - int varR, varG, varB; + int varR=0, varG=0, varB=0; if (color == RED) { varR = colorConfig.get("redChannel", 255).asInt(); @@ -618,10 +618,10 @@ MessageForwarder * Hyperion::getForwarder() Hyperion::Hyperion(const Json::Value &jsonConfig) : _ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))), _muxer(_ledString.leds().size()), - _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"])), + _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])), _raw2ledCorrection(createLedColorsCorrection(_ledString.leds().size(), jsonConfig["color"])), _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"])), - _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])), + _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"])), _device(LedDeviceFactory::construct(jsonConfig["device"])), _effectEngine(nullptr), _messageForwarder(createMessageForwarder(jsonConfig["forwarder"])), diff --git a/libsrc/hyperion/LinearColorSmoothing.cpp b/libsrc/hyperion/LinearColorSmoothing.cpp index bfb7c603..09f2b014 100644 --- a/libsrc/hyperion/LinearColorSmoothing.cpp +++ b/libsrc/hyperion/LinearColorSmoothing.cpp @@ -14,7 +14,8 @@ LinearColorSmoothing::LinearColorSmoothing( _updateInterval(1000 / ledUpdateFrequency_hz), _settlingTime(settlingTime_ms), _timer(), - _outputDelay(updateDelay) + _outputDelay(updateDelay), + _writeToLedsEnable(true) { _timer.setSingleShot(false); _timer.setInterval(_updateInterval); @@ -82,9 +83,11 @@ void LinearColorSmoothing::updateLeds() _previousTime = now; queueColors(_previousValues); + _writeToLedsEnable = false; } else { + _writeToLedsEnable = true; float k = 1.0f - 1.0f * deltaTime / (_targetTime - _previousTime); for (size_t i = 0; i < _previousValues.size(); ++i) @@ -107,7 +110,8 @@ void LinearColorSmoothing::queueColors(const std::vector & ledColors) if (_outputDelay == 0) { // No output delay => immediate write - _ledDevice->write(ledColors); + if ( _writeToLedsEnable ) + _ledDevice->write(ledColors); } else { @@ -116,7 +120,8 @@ void LinearColorSmoothing::queueColors(const std::vector & ledColors) // If the delay-buffer is filled pop the front and write to device if (_outputQueue.size() > _outputDelay) { - _ledDevice->write(_outputQueue.front()); + if ( _writeToLedsEnable ) + _ledDevice->write(_outputQueue.front()); _outputQueue.pop_front(); } } diff --git a/libsrc/hyperion/LinearColorSmoothing.h b/libsrc/hyperion/LinearColorSmoothing.h index 2b75059e..19cc915f 100644 --- a/libsrc/hyperion/LinearColorSmoothing.h +++ b/libsrc/hyperion/LinearColorSmoothing.h @@ -80,4 +80,6 @@ private: /** The output queue */ std::list > _outputQueue; + // prevent sending data to device when no intput data is sent + bool _writeToLedsEnable; }; diff --git a/libsrc/utils/RgbChannelCorrection.cpp b/libsrc/utils/RgbChannelCorrection.cpp index 2cced20b..7fb16884 100644 --- a/libsrc/utils/RgbChannelCorrection.cpp +++ b/libsrc/utils/RgbChannelCorrection.cpp @@ -6,8 +6,8 @@ RgbChannelCorrection::RgbChannelCorrection() : _correctionR(255), - _correctionB(255), - _correctionG(255) + _correctionG(255), + _correctionB(255) { initializeMapping(); } From f9690b03f43f9f6823beb007a40a4418ade89f2a Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 25 May 2016 22:04:49 -0700 Subject: [PATCH 2/2] updated reference to rpi_ws281x sub module to point to penfold42 fork (#655) * Removed -HUP so the default -TERM signal is sent instead. - hyperiond only listens for TERM and INT. HUP is often used to get an exe to reread its config Changed pgrep to add '-x' so it wont partial match on the exe name. - I have multiple instances with multiple hyperiond-instance1 names - this ensures the service script only kills the right process * reversing errant change to hyperion.systemd.sh * cleaned up a couple of compiler warnings * moved bitpair_to_byte initialiser to (hopefully) work with older GCC * compiler warning in udp driver removed some tabs in ws2812b.cpp * formatting - spaces to tabs * moved rpi_281x to tag sk6812-v1.0 * moving to my fork of rpi_281x Former-commit-id: 34ca0f4f760c6cbb47d3c434c920827ce12bb23e --- .gitmodules | 2 +- dependencies/external/rpi_ws281x | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index c23ec3d2..462e3f07 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/tvdzwan/protobuf.git [submodule "dependencies/external/rpi_ws281x"] path = dependencies/external/rpi_ws281x - url = https://github.com/jgarff/rpi_ws281x + url = https://github.com/penfold42/rpi_ws281x diff --git a/dependencies/external/rpi_ws281x b/dependencies/external/rpi_ws281x index 0165896a..dfcf7408 160000 --- a/dependencies/external/rpi_ws281x +++ b/dependencies/external/rpi_ws281x @@ -1 +1 @@ -Subproject commit 0165896aa04b08a777fb6732a1af6fa29e4a93c5 +Subproject commit dfcf740848898b432fe3a3170417de60f81521ee