From 0414e3c8609617ca498493dfb9b11c1c982c0e69 Mon Sep 17 00:00:00 2001 From: redPanther Date: Tue, 20 Dec 2016 19:55:54 +0100 Subject: [PATCH] implement states for components_autoselect and ledMAppingType via json (#344) --- include/hyperion/Hyperion.h | 5 +++++ include/hyperion/ImageProcessor.h | 1 + libsrc/hyperion/Hyperion.cpp | 9 ++++----- libsrc/hyperion/ImageProcessor.cpp | 8 ++++++++ libsrc/jsonserver/JsonClientConnection.cpp | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 75eae380..5481de5d 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -183,6 +183,9 @@ public: bool configWriteable(); + /// gets the methode how image is maped to leds + int getLedMappingType() { return _ledMAppingType; }; + public slots: /// /// Writes a single color to all the leds for the given time and priority @@ -406,4 +409,6 @@ private: QByteArray _configHash; QSize _ledGridSize; + + int _ledMAppingType; }; diff --git a/include/hyperion/ImageProcessor.h b/include/hyperion/ImageProcessor.h index 15a9fbc7..ee53c7ff 100644 --- a/include/hyperion/ImageProcessor.h +++ b/include/hyperion/ImageProcessor.h @@ -50,6 +50,7 @@ public: int ledMappingType(); static int mappingTypeToInt(QString mappingType); + static QString mappingTypeToStr(int mappingType); public slots: /// Enable or disable the black border detector diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 6788f9f1..7145b69c 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -560,11 +560,9 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile) InfoIf(_colorAdjustmentV4Lonly , _log, "Color adjustment for v4l inputs only" ); // initialize the image processor factory - ImageProcessorFactory::getInstance().init( - _ledString, - qjsonConfig["blackborderdetector"].toObject(), - ImageProcessor::mappingTypeToInt(color["imageToLedMappingType"].toString()) - ); + _ledMAppingType = ImageProcessor::mappingTypeToInt(color["imageToLedMappingType"].toString()); + ImageProcessorFactory::getInstance().init(_ledString, qjsonConfig["blackborderdetector"].toObject(),_ledMAppingType ); + getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled()); // initialize leddevices @@ -856,6 +854,7 @@ int Hyperion::setEffect(const QString &effectName, const QJsonObject &args, int void Hyperion::setLedMappingType(int mappingType) { + _ledMAppingType = mappingType; emit imageToLedsMappingChanged(mappingType); } diff --git a/libsrc/hyperion/ImageProcessor.cpp b/libsrc/hyperion/ImageProcessor.cpp index e8508fc4..52d48fd0 100644 --- a/libsrc/hyperion/ImageProcessor.cpp +++ b/libsrc/hyperion/ImageProcessor.cpp @@ -76,6 +76,14 @@ int ImageProcessor::mappingTypeToInt(QString mappingType) return 0; } +QString ImageProcessor::mappingTypeToStr(int mappingType) +{ + if (mappingType == 1 ) + return "unicolor_mean"; + + return "mulicolor_mean"; +} + bool ImageProcessor::getScanParameters(size_t led, double &hscanBegin, double &hscanEnd, double &vscanBegin, double &vscanEnd) const { if (led < _ledString.leds().size()) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 1d1a252f..476d5605 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -836,6 +836,8 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt } info["components"] = component; + info["components_autoselect"] = _hyperion->sourceAutoSelectEnabled(); + info["ledMAppingType"] = ImageProcessor::mappingTypeToStr(_hyperion->getLedMappingType()); // Add Hyperion Version, build time QJsonArray hyperion;