From d414942e2ead591e8cbb9372ea6a8a6bd115f99f Mon Sep 17 00:00:00 2001 From: Paulchen-Panther Date: Tue, 2 Jul 2019 19:06:36 +0200 Subject: [PATCH 1/2] Bugfix/Hotfix/Update Signed-off-by: Paulchen-Panther --- assets/webconfig/js/content_leds.js | 9 ++- config/hyperion.config.json.commented | 2 +- include/api/JsonAPI.h | 8 +-- include/hyperion/Hyperion.h | 21 ++++-- include/hyperion/ImageProcessor.h | 2 +- include/hyperion/ImageToLedsMap.h | 6 +- include/leddevice/LedDevice.h | 8 +++ include/utils/hyperion.h | 4 +- libsrc/effectengine/EffectEngine.cpp | 1 - libsrc/hyperion/CaptureCont.cpp | 4 +- libsrc/hyperion/Hyperion.cpp | 72 +++++++++---------- libsrc/hyperion/LinearColorSmoothing.h | 1 - libsrc/hyperion/MessageForwarder.cpp | 38 ++++++++-- libsrc/leddevice/LedDevice.cpp | 13 +--- libsrc/leddevice/LedDeviceWrapper.cpp | 33 ++++----- .../leddevice/dev_net/LedDeviceFadeCandy.cpp | 29 ++++---- libsrc/leddevice/dev_net/LedDeviceFadeCandy.h | 9 +-- libsrc/leddevice/dev_net/ProviderUdp.h | 2 +- .../leddevice/schemas/schema-fadecandy.json | 1 + src/hyperiond/hyperiond.cpp | 1 + 20 files changed, 149 insertions(+), 115 deletions(-) diff --git a/assets/webconfig/js/content_leds.js b/assets/webconfig/js/content_leds.js index 041883eb..13a1ae92 100644 --- a/assets/webconfig/js/content_leds.js +++ b/assets/webconfig/js/content_leds.js @@ -193,10 +193,10 @@ function createClassicLeds(){ } } - createLeftLeds(); - createBottomLeds(); - createRightLeds(); createTopLeds(); + createRightLeds(); + createBottomLeds(); + createLeftLeds(); //check led gap pos if (ledsgpos+ledsglength > ledArray.length) @@ -429,6 +429,9 @@ $(document).ready(function() { // create and update editor $("#leddevices").off().on("change", function() { var generalOptions = window.serverSchema.properties.device; + + // Modified schema enty "hardwareLedCount" in generalOptions to minimum LedCount + var specificOptions = window.serverSchema.properties.alldevices[$(this).val()]; conf_editor = createJsonEditor('editor_container', { generalOptions : generalOptions, diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index b387dbd0..959c06be 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -31,7 +31,7 @@ "output" : "/dev/null", "rate" : 1000000, "colorOrder" : "rgb", - "rewriteTime": 0 + "rewriteTime": 5000 }, /// Color manipulation configuration used to tune the output colors to specific surroundings. diff --git a/include/api/JsonAPI.h b/include/api/JsonAPI.h index caeb4742..fd268e0f 100644 --- a/include/api/JsonAPI.h +++ b/include/api/JsonAPI.h @@ -6,7 +6,7 @@ #include #include -// qt includess +// qt includes #include #include #include @@ -63,8 +63,8 @@ private: // true if further callbacks are forbidden (http) bool _noListener; - /// The peer address of the client - QString _peerAddress; + /// The peer address of the client + QString _peerAddress; /// Log instance Logger* _log; @@ -86,7 +86,7 @@ private: /// mutex to determine state of image streaming QMutex _image_stream_mutex; - /// mutex to determine state of image streaming + /// mutex to determine state of led streaming QMutex _led_stream_mutex; /// timeout for live video refresh diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 6894b4ff..c0edc66e 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -5,7 +5,6 @@ #include // QT includes -//#include #include #include #include @@ -13,6 +12,7 @@ #include #include #include +#include // hyperion-utils includes #include @@ -410,8 +410,11 @@ signals: /// Signal which is emitted, when a new json message should be forwarded void forwardJsonMessage(QJsonObject); - /// Signal which is emitted, when a new proto image should be forwarded - void forwardProtoMessage(const QString, const Image); + /// Signal which is emitted, when a new system proto image should be forwarded + void forwardSystemProtoMessage(const QString, const Image); + + /// Signal which is emitted, when a new V4l proto image should be forwarded + void forwardV4lProtoMessage(const QString, const Image); /// /// @brief Is emitted from clients who request a videoMode change @@ -474,6 +477,12 @@ private slots: /// void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config); + /// + /// @brief Handle priority updates from Priority Muxer + /// @param priority The new visible priority + /// + void handlePriorityChanges(const quint8 &priority); + private: /// @@ -560,12 +569,12 @@ private: /// Capture control for Daemon native capture CaptureCont* _captureCont; - // lock Hyperion::update() for exec - bool _lockUpdate = false; - /// buffer for leds (with adjustment) std::vector _ledBuffer; /// Boblight instance BoblightServer* _boblightServer; + + /// mutex + QMutex _changes; }; diff --git a/include/hyperion/ImageProcessor.h b/include/hyperion/ImageProcessor.h index d2c16216..2afaba4f 100644 --- a/include/hyperion/ImageProcessor.h +++ b/include/hyperion/ImageProcessor.h @@ -150,7 +150,7 @@ public: // Check black border detection verifyBorder(image); - // Determine the mean-colors of each led (using the existing mapping) + // Determine the mean or uni colors of each led (using the existing mapping) switch (_mappingType) { case 1: _imageToLeds->getUniLedColor(image, ledColors); break; diff --git a/include/hyperion/ImageToLedsMap.h b/include/hyperion/ImageToLedsMap.h index 2314c3ff..f58e19c5 100644 --- a/include/hyperion/ImageToLedsMap.h +++ b/include/hyperion/ImageToLedsMap.h @@ -61,7 +61,7 @@ namespace hyperion unsigned verticalBorder() { return _verticalBorder; }; /// - /// Determines the mean-color for each led using the mapping the image given + /// Determines the mean color for each led using the mapping the image given /// at construction. /// /// @param[in] image The image from which to extract the led colors @@ -104,7 +104,7 @@ namespace hyperion } /// - /// Determines the mean-color for each led using the mapping the image given + /// Determines the uni color for each led using the mapping the image given /// at construction. /// /// @param[in] image The image from which to extract the led colors @@ -120,7 +120,7 @@ namespace hyperion } /// - /// Determines the mean color for each led using the mapping the image given + /// Determines the uni color for each led using the mapping the image given /// at construction. /// /// @param[in] image The image from which to extract the led colors diff --git a/include/leddevice/LedDevice.h b/include/leddevice/LedDevice.h index 7f9c919c..b608283a 100644 --- a/include/leddevice/LedDevice.h +++ b/include/leddevice/LedDevice.h @@ -84,6 +84,14 @@ signals: /// void enableStateChanged(bool newState); + /// + /// PIPER signal for Priority Muxer -> LedDevice + /// + /// @brief Handle priority updates from Priority Muxer + /// @param priority The new visible priority + /// + void visiblePriorityChanged(const quint8 &priority); + protected: virtual bool init(const QJsonObject &deviceConfig); diff --git a/include/utils/hyperion.h b/include/utils/hyperion.h index d70263cb..10a3569b 100644 --- a/include/utils/hyperion.h +++ b/include/utils/hyperion.h @@ -40,12 +40,12 @@ namespace hyperion { (uint8_t)FGCONFIG_ARRAY.at(2).toInt(0) }; hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms); - Info(Logger::getInstance("HYPERION"),"Inital foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue); + Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue); } else { int result = hyperion->setEffect(fgEffectConfig, FG_PRIORITY, fg_duration_ms); - Info(Logger::getInstance("HYPERION"),"Inital foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed")); + Info(Logger::getInstance("HYPERION"),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed")); } } #undef FGCONFIG_ARRAY diff --git a/libsrc/effectengine/EffectEngine.cpp b/libsrc/effectengine/EffectEngine.cpp index e99c73da..8e781663 100644 --- a/libsrc/effectengine/EffectEngine.cpp +++ b/libsrc/effectengine/EffectEngine.cpp @@ -30,7 +30,6 @@ EffectEngine::EffectEngine(Hyperion * hyperion) { Q_INIT_RESOURCE(EffectEngine); - qRegisterMetaType>("std::vector"); qRegisterMetaType("hyperion::Components"); // connect the Hyperion channel clear feedback diff --git a/libsrc/hyperion/CaptureCont.cpp b/libsrc/hyperion/CaptureCont.cpp index 6c09dda2..262cb61c 100644 --- a/libsrc/hyperion/CaptureCont.cpp +++ b/libsrc/hyperion/CaptureCont.cpp @@ -73,7 +73,7 @@ void CaptureCont::setSystemCaptureEnable(const bool& enable) { _hyperion->registerInput(_systemCaptPrio, hyperion::COMP_GRABBER); connect(GlobalSignals::getInstance(), &GlobalSignals::setSystemImage, this, &CaptureCont::handleSystemImage); - connect(GlobalSignals::getInstance(), &GlobalSignals::setSystemImage, _hyperion, &Hyperion::forwardProtoMessage); + connect(GlobalSignals::getInstance(), &GlobalSignals::setSystemImage, _hyperion, &Hyperion::forwardSystemProtoMessage); } else { @@ -94,7 +94,7 @@ void CaptureCont::setV4LCaptureEnable(const bool& enable) { _hyperion->registerInput(_v4lCaptPrio, hyperion::COMP_V4L); connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, this, &CaptureCont::handleV4lImage); - connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, _hyperion, &Hyperion::forwardProtoMessage); + connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, _hyperion, &Hyperion::forwardV4lProtoMessage); } else { diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 769e7348..2f21c326 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -106,8 +106,8 @@ Hyperion::Hyperion(HyperionDaemon* daemon, const quint8& instance, const QString _ledStringColorOrder.insert(_ledStringColorOrder.begin() + led.index, led.colorOrder); } - // connect Hyperion::update with Muxer visible priority changes as muxer updates independent - connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::update); + // connect Hyperion::handlePriorityChanges with Muxer visible priority changes as muxer updates independent + connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handlePriorityChanges); // listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState); @@ -186,7 +186,6 @@ void Hyperion::freeObjects(bool emitCloseSignal) delete _boblightServer; delete _captureCont; delete _effectEngine; - //delete _deviceSmooth; delete _raw2ledAdjustment; delete _messageForwarder; delete _settingsManager; @@ -209,10 +208,13 @@ void Hyperion::handleSettingsUpdate(const settings::type& type, const QJsonDocum } else if(type == settings::LEDS) { + QMutexLocker lock(&_changes); + const QJsonArray leds = config.array(); - // lock update() - _lockUpdate = true; +// // lock update() +// _lockUpdate = true; + // stop and cache all running effects, as effects depend heavily on ledlayout _effectEngine->cacheRunningEffects(); @@ -249,12 +251,13 @@ void Hyperion::handleSettingsUpdate(const settings::type& type, const QJsonDocum // start cached effects _effectEngine->startCachedEffects(); - // unlock - _lockUpdate = false; +// // unlock +// _lockUpdate = false; } else if(type == settings::DEVICE) { - _lockUpdate = true; + QMutexLocker lock(&_changes); +// _lockUpdate = true; QJsonObject dev = config.object(); // handle hwLedCount update @@ -278,7 +281,7 @@ void Hyperion::handleSettingsUpdate(const settings::type& type, const QJsonDocum // do always reinit until the led devices can handle dynamic changes dev["currentLedCount"] = int(_hwLedCount); // Inject led count info _ledDeviceWrapper->createLedDevice(dev); - _lockUpdate = false; +// _lockUpdate = false; } // update once to push single color sets / adjustments/ ledlayout resizes and update ledBuffer color update(); @@ -578,50 +581,25 @@ void Hyperion::updatedComponentState(const hyperion::Components comp, const bool void Hyperion::update() { - if(_lockUpdate) - return; - - // the ledbuffer resize for hwledcount needs to be reverted - if(_hwLedCount > _ledBuffer.size()) - _ledBuffer.resize(getLedCount()); + QMutexLocker lock(&_changes); // Obtain the current priority channel int priority = _muxer.getCurrentPriority(); const PriorityMuxer::InputInfo priorityInfo = _muxer.getInputInfo(priority); - // eval comp change - bool compChanged = false; - if (priorityInfo.componentId != _prevCompId) - { - compChanged = true; - _prevCompId = priorityInfo.componentId; - } - // copy image & process OR copy ledColors from muxer Image image = priorityInfo.image; if(image.size() > 3) { emit currentImage(image); - // disable the black border detector for effects and ledmapping to 0 - if(compChanged) - { - _imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT)); - _imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1); - } - _imageProcessor->process(image, _ledBuffer); + _ledBuffer = _imageProcessor->process(image); } else - { _ledBuffer = priorityInfo.ledColors; - } // emit rawLedColors before transform emit rawLedColors(_ledBuffer); - // apply adjustments - if(compChanged) - _raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT)); - _raw2ledAdjustment->applyAdjustment(_ledBuffer); // insert cloned leds into buffer @@ -660,7 +638,8 @@ void Hyperion::update() } i++; } - // fill aditional hw leds with black + + // fill additional hw leds with black if ( _hwLedCount > _ledBuffer.size() ) { _ledBuffer.resize(_hwLedCount, ColorRgb::BLACK); @@ -671,7 +650,7 @@ void Hyperion::update() { _deviceSmooth->selectConfig(priorityInfo.smooth_cfg); - // feed smoothing in pause mode to maintain a smooth transistion back to smoth mode + // feed smoothing in pause mode to maintain a smooth transistion back to smooth mode if (_deviceSmooth->enabled() || _deviceSmooth->pause()) _deviceSmooth->setLedValues(_ledBuffer); @@ -679,3 +658,20 @@ void Hyperion::update() emit ledDeviceData(_ledBuffer); } } + +void Hyperion::handlePriorityChanges(const quint8 &priority) +{ + QMutexLocker lock(&_changes); + + // Obtain the current priority channel + const PriorityMuxer::InputInfo priorityInfo = _muxer.getInputInfo(priority); + + // evaluate comp change + if (priorityInfo.componentId != _prevCompId) + { + _imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT)); + _imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1); + _prevCompId = priorityInfo.componentId; + _raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT)); + } +} diff --git a/libsrc/hyperion/LinearColorSmoothing.h b/libsrc/hyperion/LinearColorSmoothing.h index e84b0384..a0d3a4b4 100644 --- a/libsrc/hyperion/LinearColorSmoothing.h +++ b/libsrc/hyperion/LinearColorSmoothing.h @@ -3,7 +3,6 @@ // STL includes #include - // Qt includes #include diff --git a/libsrc/hyperion/MessageForwarder.cpp b/libsrc/hyperion/MessageForwarder.cpp index ef1423f7..22bb0c3d 100644 --- a/libsrc/hyperion/MessageForwarder.cpp +++ b/libsrc/hyperion/MessageForwarder.cpp @@ -83,9 +83,12 @@ void MessageForwarder::handleSettingsUpdate(const settings::type &type, const QJ if (!_protoSlaves.isEmpty() && obj["enable"].toBool() && _forwarder_enabled) { InfoIf(obj["enable"].toBool(true), _log, "Forward now to proto targets '%s'", QSTRING_CSTR(_protoSlaves.join(", "))); - connect(_hyperion, &Hyperion::forwardProtoMessage, this, &MessageForwarder::forwardProtoMessage, Qt::UniqueConnection); +// connect(_hyperion, &Hyperion::forwardProtoMessage, this, &MessageForwarder::forwardProtoMessage, Qt::UniqueConnection); } else if ( _protoSlaves.isEmpty() || ! obj["enable"].toBool() || !_forwarder_enabled) - disconnect(_hyperion, &Hyperion::forwardProtoMessage, 0, 0); + { + disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0); + disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0); + } // update comp state _hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, obj["enable"].toBool(true)); @@ -112,8 +115,8 @@ void MessageForwarder::handlePriorityChanges(const quint8 &priority) while (!_forwardClients.isEmpty()) delete _forwardClients.takeFirst(); - hyperion::Components activePrio = _hyperion->getPriorityInfo(priority).componentId; - if (activePrio == hyperion::COMP_GRABBER || activePrio == hyperion::COMP_V4L) + hyperion::Components activeCompId = _hyperion->getPriorityInfo(priority).componentId; + if (activeCompId == hyperion::COMP_GRABBER || activeCompId == hyperion::COMP_V4L) { if ( !obj["proto"].isNull() ) { @@ -123,10 +126,33 @@ void MessageForwarder::handlePriorityChanges(const quint8 &priority) addProtoSlave(entry.toString()); } } - connect(_hyperion, &Hyperion::forwardProtoMessage, this, &MessageForwarder::forwardProtoMessage, Qt::UniqueConnection); + + switch(activeCompId) + { + case hyperion::COMP_GRABBER: + { + disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0); + connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardProtoMessage, Qt::UniqueConnection); + } + break; + case hyperion::COMP_V4L: + { + disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0); + connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardProtoMessage, Qt::UniqueConnection); + } + break; + default: + { + disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0); + disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0); + } + } } else - disconnect(_hyperion, &Hyperion::forwardProtoMessage, 0, 0); + { + disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0); + disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0); + } } } diff --git a/libsrc/leddevice/LedDevice.cpp b/libsrc/leddevice/LedDevice.cpp index 410c85cb..16193ec7 100644 --- a/libsrc/leddevice/LedDevice.cpp +++ b/libsrc/leddevice/LedDevice.cpp @@ -10,6 +10,8 @@ #include "hyperion/Hyperion.h" #include +#include + LedDevice::LedDevice(const QJsonObject& config, QObject* parent) : QObject(parent) , _devConfig(config) @@ -43,21 +45,12 @@ void LedDevice::setEnable(bool enable) { // emit signal when state changed if (_enabled != enable) - { emit enableStateChanged(enable); - } // set black to leds when they should go off if ( _enabled && !enable) - { switchOff(); - } - else { - if ( !_enabled && enable) - { - switchOn(); - } - } + _enabled = enable; } diff --git a/libsrc/leddevice/LedDeviceWrapper.cpp b/libsrc/leddevice/LedDeviceWrapper.cpp index ee6a1d54..3e7eb86b 100644 --- a/libsrc/leddevice/LedDeviceWrapper.cpp +++ b/libsrc/leddevice/LedDeviceWrapper.cpp @@ -41,25 +41,26 @@ LedDeviceWrapper::~LedDeviceWrapper() void LedDeviceWrapper::createLedDevice(const QJsonObject& config) { if(_ledDevice != nullptr) - { - stopDeviceThread(); - } + { + stopDeviceThread(); + } - // create thread and device - QThread* thread = new QThread(this); - _ledDevice = LedDeviceFactory::construct(config); - _ledDevice->moveToThread(thread); - // setup thread management - connect(thread, &QThread::started, _ledDevice, &LedDevice::start); - connect(thread, &QThread::finished, thread, &QObject::deleteLater); - connect(thread, &QThread::finished, _ledDevice, &QObject::deleteLater); + // create thread and device + QThread* thread = new QThread(this); + _ledDevice = LedDeviceFactory::construct(config); + _ledDevice->moveToThread(thread); + // setup thread management + connect(thread, &QThread::started, _ledDevice, &LedDevice::start); + connect(thread, &QThread::finished, thread, &QObject::deleteLater); + connect(thread, &QThread::finished, _ledDevice, &QObject::deleteLater); - // further signals - connect(this, &LedDeviceWrapper::write, _ledDevice, &LedDevice::write); - connect(_ledDevice, &LedDevice::enableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState); + // further signals + connect(this, &LedDeviceWrapper::write, _ledDevice, &LedDevice::write); + connect(_hyperion->getMuxerInstance(), &PriorityMuxer::visiblePriorityChanged, _ledDevice, &LedDevice::visiblePriorityChanged); + connect(_ledDevice, &LedDevice::enableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState); - // start the thread - thread->start(); + // start the thread + thread->start(); } const QJsonObject LedDeviceWrapper::getLedDeviceSchemas() diff --git a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp index e5ada501..cb01fcab 100644 --- a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp @@ -5,17 +5,17 @@ static const unsigned OPC_SET_PIXELS = 0; // OPC command codes static const unsigned OPC_SYS_EX = 255; // OPC command codes static const unsigned OPC_HEADER_SIZE = 4; // OPC header size - LedDeviceFadeCandy::LedDeviceFadeCandy(const QJsonObject &deviceConfig) -: LedDevice() + : LedDevice() + , _client(nullptr) { _deviceReady = init(deviceConfig); + _client = new QTcpSocket(this); } - LedDeviceFadeCandy::~LedDeviceFadeCandy() { - _client.close(); + _client->close(); } LedDevice* LedDeviceFadeCandy::construct(const QJsonObject &deviceConfig) @@ -23,10 +23,9 @@ LedDevice* LedDeviceFadeCandy::construct(const QJsonObject &deviceConfig) return new LedDeviceFadeCandy(deviceConfig); } - bool LedDeviceFadeCandy::init(const QJsonObject &deviceConfig) { - _client.close(); + LedDevice::init(deviceConfig); if (_ledCount > MAX_NUM_LEDS) { @@ -67,15 +66,14 @@ bool LedDeviceFadeCandy::init(const QJsonObject &deviceConfig) bool LedDeviceFadeCandy::isConnected() { - return _client.state() == QAbstractSocket::ConnectedState; + return _client->state() == QAbstractSocket::ConnectedState; } - bool LedDeviceFadeCandy::tryConnect() { - if ( _client.state() == QAbstractSocket::UnconnectedState ) { - _client.connectToHost( _host, _port); - if ( _client.waitForConnected(1000) ) + if ( _client->state() == QAbstractSocket::UnconnectedState ) { + _client->connectToHost( _host, _port); + if ( _client->waitForConnected(1000) ) { Info(_log,"fadecandy/opc: connected to %s:%i on channel %i", QSTRING_CSTR(_host), _port, _channel); if (_setFcConfig) @@ -88,7 +86,6 @@ bool LedDeviceFadeCandy::tryConnect() return isConnected(); } - int LedDeviceFadeCandy::write( const std::vector & ledValues ) { uint idx = OPC_HEADER_SIZE; @@ -103,11 +100,11 @@ int LedDeviceFadeCandy::write( const std::vector & ledValues ) return ( transferData()<0 ? -1 : 0 ); } - int LedDeviceFadeCandy::transferData() { - if ( isConnected() || tryConnect() ) - return _client.write( _opc_data, _opc_data.size() ); + if (LedDevice::enabled()) + if ( isConnected() || tryConnect() ) + return _client->write( _opc_data, _opc_data.size() ); return -2; } @@ -131,7 +128,7 @@ int LedDeviceFadeCandy::sendSysEx(uint8_t systemId, uint8_t commandId, QByteArra sysExData += msg; - return _client.write( sysExData, sysExData.size() ); + return _client->write( sysExData, sysExData.size() ); } return -1; } diff --git a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h index 11cd6f68..7d8318ad 100644 --- a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h +++ b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h @@ -56,17 +56,18 @@ public: /// @return true if success bool init(const QJsonObject &deviceConfig); +private: /// /// Writes the led color values to the led-device /// /// @param ledValues The color-value per led /// @return Zero on succes else negative /// - virtual int write(const std::vector & ledValues); + virtual int write(const std::vector& ledValues); -private: - QTcpSocket _client; - QString _host; +protected: + QTcpSocket* _client; + QString _host; uint16_t _port; unsigned _channel; QByteArray _opc_data; diff --git a/libsrc/leddevice/dev_net/ProviderUdp.h b/libsrc/leddevice/dev_net/ProviderUdp.h index 316902bd..b1532593 100644 --- a/libsrc/leddevice/dev_net/ProviderUdp.h +++ b/libsrc/leddevice/dev_net/ProviderUdp.h @@ -41,7 +41,7 @@ public: protected: /// - /// Writes the given bytes/bits to the SPI-device and sleeps the latch time to ensure that the + /// Writes the given bytes/bits to the UDP-device and sleeps the latch time to ensure that the /// values are latched. /// /// @param[in] size The length of the data diff --git a/libsrc/leddevice/schemas/schema-fadecandy.json b/libsrc/leddevice/schemas/schema-fadecandy.json index 78ef8241..e159d1f5 100644 --- a/libsrc/leddevice/schemas/schema-fadecandy.json +++ b/libsrc/leddevice/schemas/schema-fadecandy.json @@ -77,6 +77,7 @@ "gamma" : { "type" : "number", "title" : "edt_dev_spec_gamma_title", + "default": 1.0, "minimum" : 0.1, "maximum": 5.0, "options": { diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index b116c655..071b1530 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -75,6 +75,7 @@ HyperionDaemon::HyperionDaemon(QString configFile, const QString rootPath, QObje qRegisterMetaType("settings::type"); qRegisterMetaType("VideoMode"); qRegisterMetaType>("QMap"); + qRegisterMetaType>("std::vector"); // init settings _settingsManager = new SettingsManager(0,configFile); From 16b9bd7baa485dbc563e8c483e4a1e6a4945324c Mon Sep 17 00:00:00 2001 From: Paulchen-Panther Date: Tue, 2 Jul 2019 20:53:14 +0200 Subject: [PATCH 2/2] Fix Uni-/Multicolor assignment Signed-off-by: Paulchen-Panther --- include/hyperion/Hyperion.h | 6 ------ libsrc/hyperion/Hyperion.cpp | 41 ++++++++++-------------------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index c0edc66e..1c80fc06 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -477,12 +477,6 @@ private slots: /// void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config); - /// - /// @brief Handle priority updates from Priority Muxer - /// @param priority The new visible priority - /// - void handlePriorityChanges(const quint8 &priority); - private: /// diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 2f21c326..a2536000 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -106,9 +106,6 @@ Hyperion::Hyperion(HyperionDaemon* daemon, const quint8& instance, const QString _ledStringColorOrder.insert(_ledStringColorOrder.begin() + led.index, led.colorOrder); } - // connect Hyperion::handlePriorityChanges with Muxer visible priority changes as muxer updates independent - connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handlePriorityChanges); - // listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions connect(&_componentRegister, &ComponentRegister::updatedComponentState, this, &Hyperion::updatedComponentState); @@ -565,18 +562,19 @@ const QString & Hyperion::getActiveDevice() void Hyperion::updatedComponentState(const hyperion::Components comp, const bool state) { - if(comp == hyperion::COMP_ALL) + QMutexLocker lock(&_changes); + + // evaluate comp change + if (comp != _prevCompId) { - if(state) - { - // first muxer to update all inputs - _muxer.setEnable(state); - } - else - { - _muxer.setEnable(state); - } + _imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT)); + _imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1); + _prevCompId = comp; + _raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT)); } + + if(comp == hyperion::COMP_ALL) + _muxer.setEnable(state); // first muxer to update all inputs } void Hyperion::update() @@ -658,20 +656,3 @@ void Hyperion::update() emit ledDeviceData(_ledBuffer); } } - -void Hyperion::handlePriorityChanges(const quint8 &priority) -{ - QMutexLocker lock(&_changes); - - // Obtain the current priority channel - const PriorityMuxer::InputInfo priorityInfo = _muxer.getInputInfo(priority); - - // evaluate comp change - if (priorityInfo.componentId != _prevCompId) - { - _imageProcessor->setBlackbarDetectDisable((_prevCompId == hyperion::COMP_EFFECT)); - _imageProcessor->setHardLedMappingType((_prevCompId == hyperion::COMP_EFFECT) ? 0 : -1); - _prevCompId = priorityInfo.componentId; - _raw2ledAdjustment->setBacklightEnabled((_prevCompId != hyperion::COMP_COLOR && _prevCompId != hyperion::COMP_EFFECT)); - } -}