diff --git a/assets/webconfig/js/content_leds.js b/assets/webconfig/js/content_leds.js index 053feaf4..113ef1db 100644 --- a/assets/webconfig/js/content_leds.js +++ b/assets/webconfig/js/content_leds.js @@ -11,7 +11,7 @@ $(document).ready(function() { } else { - ledColors = (event.response.result); + ledColors = (event.response.result.leds); for(var idx=0; idx void verifyBorder(const Image & image) { + if (!_borderProcessor->enabled() && ( _imageToLeds->horizontalBorder()!=0 || _imageToLeds->verticalBorder()!=0 )) + { + Debug(Logger::getInstance("BLACKBORDER"), "disabled, reset border"); + _borderProcessor->process(image); + delete _imageToLeds; + _imageToLeds = new hyperion::ImageToLedsMap(image.width(), image.height(), 0, 0, _ledString.leds()); + } + if(_borderProcessor->enabled() && _borderProcessor->process(image)) { Debug(Logger::getInstance("BLACKBORDER"), "BORDER SWITCH REQUIRED!!"); diff --git a/include/hyperion/ImageToLedsMap.h b/include/hyperion/ImageToLedsMap.h index 7c9f375a..47a39305 100644 --- a/include/hyperion/ImageToLedsMap.h +++ b/include/hyperion/ImageToLedsMap.h @@ -56,6 +56,9 @@ namespace hyperion /// unsigned height() const; + const unsigned horizontalBorder() const { return _horizontalBorder; }; + const unsigned verticalBorder() const { return _verticalBorder; }; + /// /// Determines the mean-color for each led using the mapping the image given /// at construction. @@ -99,6 +102,11 @@ namespace hyperion const unsigned _width; /// The height of the indexed image const unsigned _height; + + const unsigned _horizontalBorder; + + const unsigned _verticalBorder; + /// The absolute indices into the image for each led std::vector> mColorsMap; diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index c74b6f1a..03ba1f9b 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -497,34 +497,34 @@ LedString Hyperion::createLedStringClone(const Json::Value& ledsConfig, const Co return ledString; } -LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice) +LinearColorSmoothing * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, LedDevice* leddevice) { Logger * log = Logger::getInstance("Core"); std::string type = smoothingConfig.get("type", "linear").asString(); std::transform(type.begin(), type.end(), type.begin(), ::tolower); - + LinearColorSmoothing * device; type = "linear"; // TODO currently hardcoded type, delete it if we have more types - if ( ! smoothingConfig.get("enable", true).asBool() ) - { - Info(log,"Smoothing disabled"); - Hyperion::getInstance()->getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, false); - return nullptr; - } - + if (type == "linear") { - Info(log, "Creating linear smoothing"); - return new LinearColorSmoothing( - ledDevice, + Info( log, "Creating linear smoothing"); + device = new LinearColorSmoothing( + leddevice, smoothingConfig.get("updateFrequency", 25.0).asDouble(), smoothingConfig.get("time_ms", 200).asInt(), smoothingConfig.get("updateDelay", 0).asUInt(), smoothingConfig.get("continuousOutput", true).asBool() ); } + else + { + Error(log, "Smoothing disabled, because of unknown type '%s'.", type.c_str()); + } + + device->setEnable(smoothingConfig.get("enable", true).asBool()); + InfoIf(!device->enabled(), log,"Smoothing disabled"); - Error(log, "Smoothing disabled, because of unknown type '%s'.", type.c_str()); - return nullptr; + return device; } MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig) @@ -575,7 +575,6 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile) , _hwLedCount(_ledString.leds().size()) , _sourceAutoSelectEnabled(true) { - _device = LedDeviceFactory::construct(jsonConfig["device"]); registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY); if (!_raw2ledAdjustment->verifyAdjustments()) @@ -604,18 +603,12 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile) _ledString, jsonConfig["blackborderdetector"] ); - //_hyperion->getComponentRegister().componentStateChanged(component, _processor->blackBorderDetectorEnabled()); - getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled()); - - // initialize the color smoothing filter - LedDevice* smoothing = createColorSmoothing(jsonConfig["smoothing"], _device); - if ( smoothing != nullptr ) - { - _device = smoothing; - getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, ((LinearColorSmoothing*)_device)->componentState()); - connect(this, SIGNAL(componentStateChanged(hyperion::Components,bool)), (LinearColorSmoothing*)_device, SLOT(componentStateChanged(hyperion::Components,bool))); - } + + // initialize leddevices + _device = LedDeviceFactory::construct(jsonConfig["device"]); + _deviceSmooth = createColorSmoothing(jsonConfig["smoothing"], _device); + getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, _deviceSmooth->componentState()); // setup the timer _timer.setSingleShot(true); @@ -700,7 +693,15 @@ bool Hyperion::setCurrentSourcePriority(int priority ) void Hyperion::setComponentState(const hyperion::Components component, const bool state) { - emit componentStateChanged(component, state); + if (component == hyperion::COMP_SMOOTHING) + { + _deviceSmooth->setEnable(state); + getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, _deviceSmooth->componentState()); + } + else + { + emit componentStateChanged(component, state); + } } void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms, bool clearEffects) @@ -931,7 +932,10 @@ void Hyperion::update() } // Write the data to the device - _device->write(_ledBuffer); + if (_deviceSmooth->enabled()) + _deviceSmooth->write(_ledBuffer); + else + _device->write(_ledBuffer); // Start the timeout-timer if (priorityInfo.timeoutTime_ms == -1) diff --git a/libsrc/hyperion/ImageToLedsMap.cpp b/libsrc/hyperion/ImageToLedsMap.cpp index aa309768..43b0ec8b 100644 --- a/libsrc/hyperion/ImageToLedsMap.cpp +++ b/libsrc/hyperion/ImageToLedsMap.cpp @@ -13,10 +13,12 @@ ImageToLedsMap::ImageToLedsMap( const unsigned height, const unsigned horizontalBorder, const unsigned verticalBorder, - const std::vector& leds) : - _width(width), - _height(height), - mColorsMap() + const std::vector& leds) + : _width(width) + , _height(height) + , _horizontalBorder(horizontalBorder) + , _verticalBorder(verticalBorder) + , mColorsMap() { // Sanity check of the size of the borders (and width and height) assert(width > 2*verticalBorder); diff --git a/libsrc/hyperion/LinearColorSmoothing.cpp b/libsrc/hyperion/LinearColorSmoothing.cpp index df9bf2ee..404e6662 100644 --- a/libsrc/hyperion/LinearColorSmoothing.cpp +++ b/libsrc/hyperion/LinearColorSmoothing.cpp @@ -15,7 +15,7 @@ LinearColorSmoothing::LinearColorSmoothing( LedDevice * ledDevice, double ledUpd , _outputDelay(updateDelay) , _writeToLedsEnable(true) , _continuousOutput(continuousOutput) - , _bypass(false) + , _enabled(true) { _log = Logger::getInstance("Smoothing"); _timer.setSingleShot(false); @@ -35,28 +35,21 @@ LinearColorSmoothing::~LinearColorSmoothing() int LinearColorSmoothing::write(const std::vector &ledValues) { - if (_bypass) + // received a new target color + if (_previousValues.empty()) { - _ledDevice->write(ledValues); + // not initialized yet + _targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime; + _targetValues = ledValues; + + _previousTime = QDateTime::currentMSecsSinceEpoch(); + _previousValues = ledValues; + _timer.start(); } else { - // received a new target color - if (_previousValues.empty()) - { - // not initialized yet - _targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime; - _targetValues = ledValues; - - _previousTime = QDateTime::currentMSecsSinceEpoch(); - _previousValues = ledValues; - _timer.start(); - } - else - { - _targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime; - memcpy(_targetValues.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb)); - } + _targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime; + memcpy(_targetValues.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb)); } return 0; @@ -139,13 +132,13 @@ void LinearColorSmoothing::queueColors(const std::vector & ledColors) } } -void LinearColorSmoothing::componentStateChanged(const hyperion::Components component, bool enable) + +void LinearColorSmoothing::setEnable(bool enable) { - if (component == COMP_SMOOTHING) - { - InfoIf(_bypass == enable, _log, "change state to %s", (enable ? "enabled" : "disabled") ); - Hyperion::getInstance()->getComponentRegister().componentStateChanged(component, enable); - _bypass = !enable; - } + _enabled = enable; } +bool LinearColorSmoothing::enabled() +{ + return _enabled; +} diff --git a/libsrc/hyperion/LinearColorSmoothing.h b/libsrc/hyperion/LinearColorSmoothing.h index 5cd3df30..7cfc820e 100644 --- a/libsrc/hyperion/LinearColorSmoothing.h +++ b/libsrc/hyperion/LinearColorSmoothing.h @@ -40,14 +40,15 @@ public: /// Switch the leds off virtual int switchOff(); - bool componentState() { return !_bypass; } + void setEnable(bool enable); + bool enabled(); + + bool componentState() { return enabled(); }; private slots: /// Timer callback which writes updated led values to the led device void updateLeds(); - void componentStateChanged(const hyperion::Components component, bool enable); - private: /** * Pushes the colors into the output queue and popping the head to the led-device @@ -91,5 +92,5 @@ private: /// Flag for dis/enable continuous output to led device regardless there is new data or not bool _continuousOutput; - bool _bypass; + bool _enabled; }; diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 937e9948..fed1504a 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -1157,8 +1157,9 @@ bool JsonClientConnection::checkJson(const Json::Value & message, const QString void JsonClientConnection::streamLedcolorsUpdate() { - Json::Value & leds = _streaming_leds_reply["result"] = Json::Value(Json::arrayValue); - + Json::Value & leds = _streaming_leds_reply["result"]["leds"] = Json::Value(Json::arrayValue); + //QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888); + const PriorityMuxer::InputInfo & priorityInfo = _hyperion->getPriorityInfo(_hyperion->getCurrentPriority()); std::vector ledBuffer = priorityInfo.ledColors; diff --git a/test/testrunner.sh b/test/testrunner.sh index af4eb8fc..4b6d1607 100644 --- a/test/testrunner.sh +++ b/test/testrunner.sh @@ -2,7 +2,7 @@ STATS_FAILED=0 STATS_SUCCESS=0 -STATS_SKIPED=0 +STATS_SKIPPED=0 STATS_TOTAL=0 @@ -13,7 +13,7 @@ function exec_test() if [ ! -e "$2" ] then echo "skip test: '$test_name'" - (( STATS_SKIPED++ )) + (( STATS_SKIPPED++ )) return fi shift @@ -52,7 +52,7 @@ echo "TEST SUMMARY" echo "============" echo " total: $STATS_TOTAL" echo " success: $STATS_SUCCESS" -echo " skiped: $STATS_SKIPED" +echo " skipped: $STATS_SKIPPED" echo " failed: $STATS_FAILED" sleep 2