From b2a6366176f1799d3fa9a71831939b1a37d7fdbc Mon Sep 17 00:00:00 2001 From: redPanther Date: Tue, 10 Jan 2017 19:58:41 +0100 Subject: [PATCH] fix coloradjustment via hyperion remote (#362) * - fix coloradjustment via hyperion remote - several small cleanups/refactorings * fix color is shown as unknown in json serverinfo * fix active color is not shown when autoselect is reactivated --- config/hyperion.config.json.commented | 2 +- config/hyperion.config.json.default | 2 +- include/hyperion/Hyperion.h | 2 +- include/utils/Components.h | 4 +- include/utils/Logger.h | 2 +- include/utils/RgbChannelAdjustment.h | 12 +- libsrc/grabber/v4l2/V4L2Grabber.cpp | 2 +- libsrc/hyperion/Hyperion.cpp | 123 ++++++--------------- libsrc/hyperion/MultiColorAdjustment.cpp | 7 +- libsrc/hyperion/MultiColorAdjustment.h | 3 + libsrc/hyperion/PriorityMuxer.cpp | 4 +- libsrc/jsonserver/JsonClientConnection.cpp | 6 +- libsrc/utils/Logger.cpp | 18 +-- libsrc/utils/RgbChannelAdjustment.cpp | 11 +- src/hyperion-remote/JsonConnection.cpp | 16 +++ 15 files changed, 96 insertions(+), 118 deletions(-) diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index aa060eed..67b07f78 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -86,7 +86,7 @@ "gammaGreen" : 1.0, "gammaBlue" : 1.0, "brightnessMin" : 0.0, - "brightness" : 0.5 + "brightness" : 0.75 } ] }, diff --git a/config/hyperion.config.json.default b/config/hyperion.config.json.default index 03bd8998..22958e07 100644 --- a/config/hyperion.config.json.default +++ b/config/hyperion.config.json.default @@ -41,7 +41,7 @@ "gammaGreen" : 1.0, "gammaBlue" : 1.0, "brightnessMin" : 0.0, - "brightness" : 0.5 + "brightness" : 0.75 } ] }, diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index c19b9822..f320e197 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -270,7 +270,7 @@ public: static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig); static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig); static RgbTransform * createRgbTransform(const QJsonObject& colorConfig); - static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonArray& colorConfig, const RgbChannel color); + static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonObject & colorConfig, const QString channelName, const int defaultR, const int defaultG, const int defaultB); static LinearColorSmoothing * createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice); static MessageForwarder * createMessageForwarder(const QJsonObject & forwarderConfig); diff --git a/include/utils/Components.h b/include/utils/Components.h index 5ac50909..297a1c63 100644 --- a/include/utils/Components.h +++ b/include/utils/Components.h @@ -33,8 +33,8 @@ inline const char* componentToString(Components c) case COMP_BOBLIGHTSERVER:return "Boblight server"; case COMP_GRABBER: return "Framegrabber"; case COMP_V4L: return "V4L capture device"; - case COMP_COLOR: return "solid color"; - case COMP_EFFECT: return "effect"; + case COMP_COLOR: return "Solid color"; + case COMP_EFFECT: return "Effect"; default: return ""; } } diff --git a/include/utils/Logger.h b/include/utils/Logger.h index 0c19e8f6..0b1a58b2 100644 --- a/include/utils/Logger.h +++ b/include/utils/Logger.h @@ -50,7 +50,7 @@ public: QString levelString; } T_LOG_MESSAGE; - static Logger* getInstance(std::string name="", LogLevel minLevel=Logger::INFO); + static Logger* getInstance(QString name="", LogLevel minLevel=Logger::INFO); static void deleteInstance(std::string name=""); static void setLogLevel(LogLevel level,std::string name=""); static LogLevel getLogLevel(std::string name=""); diff --git a/include/utils/RgbChannelAdjustment.h b/include/utils/RgbChannelAdjustment.h index 031196f3..fae861b6 100644 --- a/include/utils/RgbChannelAdjustment.h +++ b/include/utils/RgbChannelAdjustment.h @@ -2,6 +2,8 @@ // STL includes #include +#include +#include /// Correction for a single color byte value /// All configuration values are unsigned int and assume the color value to be between 0 and 255 @@ -9,13 +11,13 @@ class RgbChannelAdjustment { public: /// Default constructor - RgbChannelAdjustment(); + RgbChannelAdjustment(QString channelName=""); /// Constructor /// @param adjustR /// @param adjustG /// @param adjustB - RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB); + RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB, QString channelName=""); /// Destructor ~RgbChannelAdjustment(); @@ -64,4 +66,10 @@ private: /// The mapping from input color to output color uint8_t _mapping[3][256]; + + /// Name of this channel, usefull for debug messages + QString _channelName; + + /// Logger instance + Logger * _log; }; diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index dcd0e9a4..8e71406b 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -51,7 +51,7 @@ V4L2Grabber::V4L2Grabber(const std::string & device , _noSignalCounter(0) , _streamNotifier(nullptr) , _imageResampler() - , _log(Logger::getInstance("V4L2:"+device)) + , _log(Logger::getInstance("V4L2:"+QString::fromStdString(device))) , _initialized(false) , _deviceAutoDiscoverEnabled(false) , _noSignalDetected(false) diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 5416d987..de7a82f9 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -30,6 +30,8 @@ // effect engine includes #include +#define CORE_LOGGER Logger::getInstance("Core") + Hyperion* Hyperion::_hyperion = nullptr; Hyperion* Hyperion::initInstance(const QJsonObject& qjsonConfig, const QString configFile) // REMOVE jsonConfig variable when the conversion from jsonCPP to QtJSON is finished @@ -57,25 +59,15 @@ ColorOrder Hyperion::createColorOrder(const QJsonObject &deviceConfig) ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustmentConfig) { const std::string id = adjustmentConfig["id"].toString("default").toStdString(); - - // QT5.4 needed - //~ RgbChannelAdjustment * blackAdjustment = createRgbChannelAdjustment(adjustmentConfig["black"]. toArray(QJsonArray({"0","0","0" }))); - //~ RgbChannelAdjustment * whiteAdjustment = createRgbChannelAdjustment(adjustmentConfig["white"]. toArray(QJsonArray({"255","255","255"}))); - //~ RgbChannelAdjustment * redAdjustment = createRgbChannelAdjustment(adjustmentConfig["red"]. toArray(QJsonArray({"255","0","0" }))); - //~ RgbChannelAdjustment * greenAdjustment = createRgbChannelAdjustment(adjustmentConfig["green"]. toArray(QJsonArray({"0","255","0" }))); - //~ RgbChannelAdjustment * blueAdjustment = createRgbChannelAdjustment(adjustmentConfig["blue"]. toArray(QJsonArray({"0","0","255" }))); - //~ RgbChannelAdjustment * cyanAdjustment = createRgbChannelAdjustment(adjustmentConfig["cyan"]. toArray(QJsonArray({"0","255","255" }))); - //~ RgbChannelAdjustment * magentaAdjustment = createRgbChannelAdjustment(adjustmentConfig["magenta"].toArray(QJsonArray({"255","0","255" }))); - //~ RgbChannelAdjustment * yellowAdjustment = createRgbChannelAdjustment(adjustmentConfig["yellow"]. toArray(QJsonArray({"255","255","0" }))); - - RgbChannelAdjustment * blackAdjustment = createRgbChannelAdjustment(adjustmentConfig["black"].toArray(),BLACK); - RgbChannelAdjustment * whiteAdjustment = createRgbChannelAdjustment(adjustmentConfig["white"].toArray(),WHITE); - RgbChannelAdjustment * redAdjustment = createRgbChannelAdjustment(adjustmentConfig["red"].toArray(),RED); - RgbChannelAdjustment * greenAdjustment = createRgbChannelAdjustment(adjustmentConfig["green"].toArray(),GREEN); - RgbChannelAdjustment * blueAdjustment = createRgbChannelAdjustment(adjustmentConfig["blue"].toArray(),BLUE); - RgbChannelAdjustment * cyanAdjustment = createRgbChannelAdjustment(adjustmentConfig["cyan"].toArray(),CYAN); - RgbChannelAdjustment * magentaAdjustment = createRgbChannelAdjustment(adjustmentConfig["magenta"].toArray(),MAGENTA); - RgbChannelAdjustment * yellowAdjustment = createRgbChannelAdjustment(adjustmentConfig["yellow"].toArray(),YELLOW); + + RgbChannelAdjustment * blackAdjustment = createRgbChannelAdjustment(adjustmentConfig, "black" , 0, 0, 0); + RgbChannelAdjustment * whiteAdjustment = createRgbChannelAdjustment(adjustmentConfig, "white" , 255,255,255); + RgbChannelAdjustment * redAdjustment = createRgbChannelAdjustment(adjustmentConfig, "red" , 255, 0, 0); + RgbChannelAdjustment * greenAdjustment = createRgbChannelAdjustment(adjustmentConfig, "green" , 0,255, 0); + RgbChannelAdjustment * blueAdjustment = createRgbChannelAdjustment(adjustmentConfig, "blue" , 0, 0,255); + RgbChannelAdjustment * cyanAdjustment = createRgbChannelAdjustment(adjustmentConfig, "cyan" , 0,255,255); + RgbChannelAdjustment * magentaAdjustment = createRgbChannelAdjustment(adjustmentConfig, "magenta", 255, 0,255); + RgbChannelAdjustment * yellowAdjustment = createRgbChannelAdjustment(adjustmentConfig, "yellow" , 255,255, 0); RgbTransform * rgbTransform = createRgbTransform(adjustmentConfig); ColorAdjustment * adjustment = new ColorAdjustment(); @@ -109,7 +101,6 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt { // Create the result, the transforms are added to this MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt); - Logger * log = Logger::getInstance("Core"); const QJsonValue adjustmentConfig = colorConfig["channelAdjustment"]; if (adjustmentConfig.isNull()) @@ -141,13 +132,13 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt { // Special case for indices '*' => all leds adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1); - Info(log, "ColorAdjustment '%s' => [0; %d]", colorAdjustment->_id.c_str(), ledCnt-1); + Info(CORE_LOGGER, "ColorAdjustment '%s' => [0; %d]", colorAdjustment->_id.c_str(), ledCnt-1); continue; } if (!overallExp.exactMatch(ledIndicesStr)) { - Error(log, "Given led indices %d not correct format: %s", i, ledIndicesStr.toStdString().c_str()); + Error(CORE_LOGGER, "Given led indices %d not correct format: %s", i, ledIndicesStr.toStdString().c_str()); continue; } @@ -174,7 +165,7 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt ss << index; } } - Info(log, "ColorAdjustment '%s' => [%s]", colorAdjustment->_id.c_str(), ss.str().c_str()); + Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", colorAdjustment->_id.c_str(), ss.str().c_str()); } } return adjustment; @@ -192,59 +183,14 @@ RgbTransform* Hyperion::createRgbTransform(const QJsonObject& colorConfig) return transform; } -RgbChannelAdjustment* Hyperion::createRgbChannelAdjustment(const QJsonArray& colorConfig, const RgbChannel color) +RgbChannelAdjustment* Hyperion::createRgbChannelAdjustment(const QJsonObject& colorConfig, const QString channelName, const int defaultR, const int defaultG, const int defaultB) { - int varR=0, varG=0, varB=0; - if (color == BLACK) - { - varR = colorConfig[0].toInt(0); - varG = colorConfig[1].toInt(0); - varB = colorConfig[2].toInt(0); - } - else if (color == WHITE) - { - varR = colorConfig[0].toInt(255); - varG = colorConfig[1].toInt(255); - varB = colorConfig[2].toInt(255); - } - else if (color == RED) - { - varR = colorConfig[0].toInt(255); - varG = colorConfig[1].toInt(0); - varB = colorConfig[2].toInt(0); - } - else if (color == GREEN) - { - varR = colorConfig[0].toInt(0); - varG = colorConfig[1].toInt(255); - varB = colorConfig[2].toInt(0); - } - else if (color == BLUE) - { - varR = colorConfig[0].toInt(0); - varG = colorConfig[1].toInt(0); - varB = colorConfig[2].toInt(255); - } - else if (color == CYAN) - { - varR = colorConfig[0].toInt(0); - varG = colorConfig[1].toInt(255); - varB = colorConfig[2].toInt(255); - } - else if (color == MAGENTA) - { - varR = colorConfig[0].toInt(255); - varG = colorConfig[1].toInt(0); - varB = colorConfig[2].toInt(255); - } - else if (color == YELLOW) - { - varR = colorConfig[0].toInt(255); - varG = colorConfig[1].toInt(255); - varB = colorConfig[2].toInt(0); - } - - RgbChannelAdjustment* adjustment = new RgbChannelAdjustment(varR, varG, varB); + const QJsonArray& channelConfig = colorConfig[channelName].toArray(); + RgbChannelAdjustment* adjustment = new RgbChannelAdjustment( + channelConfig[0].toInt(defaultR), + channelConfig[1].toInt(defaultG), + channelConfig[2].toInt(defaultB), + "ChannelAdjust_"+channelName.toUpper()); return adjustment; } @@ -264,7 +210,7 @@ LedString Hyperion::createLedString(const QJsonValue& ledsConfig, const ColorOrd led.clone = index["clone"].toInt(-1); if ( led.clone < -1 || led.clone >= maxLedId ) { - Warning(Logger::getInstance("Core"), "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone); + Warning(CORE_LOGGER, "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone); led.clone = -1; } @@ -313,13 +259,13 @@ LedString Hyperion::createLedStringClone(const QJsonValue& ledsConfig, const Col led.clone = index["clone"].toInt(-1); if ( led.clone < -1 || led.clone >= maxLedId ) { - Warning(Logger::getInstance("Core"), "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone); + Warning(CORE_LOGGER, "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone); led.clone = -1; } if ( led.clone >= 0 ) { - Debug(Logger::getInstance("Core"), "LED %d: clone from led %d", led.index, led.clone); + Debug(CORE_LOGGER, "LED %d: clone from led %d", led.index, led.clone); led.minX_frac = 0; led.maxX_frac = 0; led.minY_frac = 0; @@ -378,7 +324,7 @@ QSize Hyperion::getLedLayoutGridSize(const QJsonValue& ledsConfig) midPointsY.erase(std::unique(midPointsY.begin(), midPointsY.end()), midPointsY.end()); QSize gridSize( midPointsX.size(), midPointsY.size() ); - Debug(Logger::getInstance("Core"), "led layout grid: %dx%d", gridSize.width(), gridSize.height()); + Debug(CORE_LOGGER, "led layout grid: %dx%d", gridSize.width(), gridSize.height()); return gridSize; } @@ -387,7 +333,6 @@ QSize Hyperion::getLedLayoutGridSize(const QJsonValue& ledsConfig) LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice) { - Logger * log = Logger::getInstance("Core"); std::string type = smoothingConfig["type"].toString("linear").toStdString(); std::transform(type.begin(), type.end(), type.begin(), ::tolower); LinearColorSmoothing * device = nullptr; @@ -395,7 +340,7 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smooth if (type == "linear") { - Info( log, "Creating linear smoothing"); + Info( CORE_LOGGER, "Creating linear smoothing"); device = new LinearColorSmoothing( leddevice, smoothingConfig["updateFrequency"].toDouble(25.0), @@ -406,11 +351,11 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smooth } else { - Error(log, "Smoothing disabled, because of unknown type '%s'.", type.c_str()); + Error(CORE_LOGGER, "Smoothing disabled, because of unknown type '%s'.", type.c_str()); } device->setEnable(smoothingConfig["enable"].toBool(true)); - InfoIf(!device->enabled(), log,"Smoothing disabled"); + InfoIf(!device->enabled(), CORE_LOGGER,"Smoothing disabled"); assert(device != nullptr); return device; @@ -426,7 +371,7 @@ MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarde const QJsonArray & addr = forwarderConfig["json"].toArray(); for (signed i = 0; i < addr.size(); ++i) { - Info(Logger::getInstance("Core"), "Json forward to %s", addr.at(i).toString().toStdString().c_str()); + Info(CORE_LOGGER, "Json forward to %s", addr.at(i).toString().toStdString().c_str()); forwarder->addJsonSlave(addr[i].toString().toStdString()); } } @@ -436,7 +381,7 @@ MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarde const QJsonArray & addr = forwarderConfig["proto"].toArray(); for (signed i = 0; i < addr.size(); ++i) { - Info(Logger::getInstance("Core"), "Proto forward to %s", addr.at(i).toString().toStdString().c_str()); + Info(CORE_LOGGER, "Proto forward to %s", addr.at(i).toString().toStdString().c_str()); forwarder->addProtoSlave(addr[i].toString().toStdString()); } } @@ -460,7 +405,7 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile) , _qjsonConfig(qjsonConfig) , _configFile(configFile) , _timer() - , _log(Logger::getInstance("Core")) + , _log(CORE_LOGGER) , _hwLedCount(_ledString.leds().size()) , _colorAdjustmentV4Lonly(false) , _sourceAutoSelectEnabled(true) @@ -599,6 +544,7 @@ void Hyperion::setSourceAutoSelectEnabled(bool enabled) { setCurrentSourcePriority(_muxer.getCurrentPriority()); } + update(); DebugIf( !_sourceAutoSelectEnabled, _log, "source auto select is disabled"); InfoIf(_sourceAutoSelectEnabled, _log, "set current input source to auto select"); } @@ -830,18 +776,15 @@ void Hyperion::update() std::swap(color.red, color.green); break; case ORDER_GBR: - { std::swap(color.red, color.green); std::swap(color.green, color.blue); break; - } + case ORDER_BRG: - { std::swap(color.red, color.blue); std::swap(color.green, color.blue); break; } - } i++; } diff --git a/libsrc/hyperion/MultiColorAdjustment.cpp b/libsrc/hyperion/MultiColorAdjustment.cpp index f707cecd..9c5ef0a4 100644 --- a/libsrc/hyperion/MultiColorAdjustment.cpp +++ b/libsrc/hyperion/MultiColorAdjustment.cpp @@ -8,6 +8,7 @@ MultiColorAdjustment::MultiColorAdjustment(const unsigned ledCnt) : _ledAdjustments(ledCnt, nullptr) + , _log(Logger::getInstance("ColorAdjust")) { } @@ -47,14 +48,14 @@ bool MultiColorAdjustment::verifyAdjustments() const if (adjustment == nullptr) { - Error(Logger::getInstance("ColorAdjust"), "No adjustment set for %d", iLed); + Error(_log, "No adjustment set for %d", iLed); return false; } if (adjustment->_rgbTransform.getBrightness() <= adjustment->_rgbTransform.getBrightnessMin() ) { adjustment->_rgbTransform.setBrightnessMin(0); adjustment->_rgbTransform.setBrightness(0.5); - Warning(Logger::getInstance("ColorAdjust"), "Adjustment for %d has invalid Brightness values, values set to default. (brightnessMin is bigger then brightness)", iLed); + Warning(_log, "Adjustment for %d has invalid Brightness values, values set to default. (brightnessMin is bigger then brightness)", iLed); } } return true; @@ -144,7 +145,7 @@ void MultiColorAdjustment::applyAdjustment(std::vector& ledColors) uint8_t WR = adjustment->_rgbWhiteAdjustment.getAdjustmentR(white); uint8_t WG = adjustment->_rgbWhiteAdjustment.getAdjustmentG(white); uint8_t WB = adjustment->_rgbWhiteAdjustment.getAdjustmentB(white); - + color.red = OR + RR + GR + BR + CR + MR + YR + WR; color.green = OG + RG + GG + BG + CG + MG + YG + WG; color.blue = OB + RB + GB + BB + CB + MB + YB + WB; diff --git a/libsrc/hyperion/MultiColorAdjustment.h b/libsrc/hyperion/MultiColorAdjustment.h index 6289818e..5d9db94c 100644 --- a/libsrc/hyperion/MultiColorAdjustment.h +++ b/libsrc/hyperion/MultiColorAdjustment.h @@ -61,4 +61,7 @@ private: /// List with a pointer to the ColorAdjustment for each individual led std::vector _ledAdjustments; + + // logger instance + Logger * _log; }; diff --git a/libsrc/hyperion/PriorityMuxer.cpp b/libsrc/hyperion/PriorityMuxer.cpp index 961df979..707109f4 100644 --- a/libsrc/hyperion/PriorityMuxer.cpp +++ b/libsrc/hyperion/PriorityMuxer.cpp @@ -50,12 +50,12 @@ const PriorityMuxer::InputInfo& PriorityMuxer::getInputInfo(const int priority) void PriorityMuxer::setInput(const int priority, const std::vector& ledColors, const int64_t timeoutTime_ms, hyperion::Components component) { - InputInfo& input = _activeInputs[priority]; + InputInfo& input = _activeInputs[priority]; input.priority = priority; input.timeoutTime_ms = timeoutTime_ms; input.ledColors = ledColors; input.componentId = component; - _currentPriority = std::min(_currentPriority, priority); + _currentPriority = std::min(_currentPriority, priority); } void PriorityMuxer::clearInput(const int priority) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index c7d8c46c..dff83e45 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -390,7 +390,7 @@ void JsonClientConnection::handleColorCommand(const QJsonObject& message, const } // set output - _hyperion->setColors(priority, colorData, duration); + _hyperion->setColors(priority, colorData, duration, true, hyperion::COMP_COLOR); // send reply sendSuccessReply(command, tan); @@ -595,7 +595,9 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt item["duration_ms"] = int(priorityInfo.timeoutTime_ms - now); } - item["owner"] = QString("unknown"); + item["owner"] = QString(hyperion::componentToIdString(priorityInfo.componentId)); + item["componentId"] = priorityInfo.componentId; + item["component"] = QString(hyperion::componentToString(priorityInfo.componentId)); item["active"] = true; item["visible"] = (priority == currentPriority); foreach(auto const &entry, priorityRegister) diff --git a/libsrc/utils/Logger.cpp b/libsrc/utils/Logger.cpp index 8faa8504..95108d22 100644 --- a/libsrc/utils/Logger.cpp +++ b/libsrc/utils/Logger.cpp @@ -17,25 +17,25 @@ std::map *Logger::LoggerMap = nullptr; Logger::LogLevel Logger::GLOBAL_MIN_LOG_LEVEL = Logger::UNSET; LoggerManager* LoggerManager::_instance = nullptr; - -Logger* Logger::getInstance(std::string name, Logger::LogLevel minLevel) +Logger* Logger::getInstance(QString name, Logger::LogLevel minLevel) { + std::string loggerName = name.toStdString(); Logger* log = nullptr; if (LoggerMap == nullptr) { LoggerMap = new std::map; } - if ( LoggerMap->find(name) == LoggerMap->end() ) + if ( LoggerMap->find(loggerName) == LoggerMap->end() ) { - log = new Logger(name,minLevel); - LoggerMap->insert(std::pair(name,log)); // compat version, replace it with following line if we have 100% c++11 - //LoggerMap->emplace(name,log); // not compat with older linux distro's e.g. wheezy + log = new Logger(loggerName,minLevel); + LoggerMap->insert(std::pair(loggerName,log)); // compat version, replace it with following line if we have 100% c++11 + //LoggerMap->emplace(loggerName,log); // not compat with older linux distro's e.g. wheezy connect(log, SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), LoggerManager::getInstance(), SLOT(handleNewLogMessage(Logger::T_LOG_MESSAGE))); } else { - log = LoggerMap->at(name); + log = LoggerMap->at(loggerName); } return log; @@ -71,7 +71,7 @@ void Logger::setLogLevel(LogLevel level,std::string name) } else { - Logger* log = Logger::getInstance(name,level); + Logger* log = Logger::getInstance(QString::fromStdString(name),level); log->setMinLevel(level); } } @@ -83,7 +83,7 @@ Logger::LogLevel Logger::getLogLevel(std::string name) return GLOBAL_MIN_LOG_LEVEL; } - Logger* log = Logger::getInstance(name); + Logger* log = Logger::getInstance(QString::fromStdString(name)); return log->getMinLevel(); } diff --git a/libsrc/utils/RgbChannelAdjustment.cpp b/libsrc/utils/RgbChannelAdjustment.cpp index 7e77dd92..53c2b350 100644 --- a/libsrc/utils/RgbChannelAdjustment.cpp +++ b/libsrc/utils/RgbChannelAdjustment.cpp @@ -6,12 +6,16 @@ // Utils includes #include -RgbChannelAdjustment::RgbChannelAdjustment() +RgbChannelAdjustment::RgbChannelAdjustment(QString channelName) + : _channelName(channelName) + , _log(Logger::getInstance(channelName)) { - setAdjustment(UINT8_MAX, UINT8_MAX, UINT8_MAX); + //setAdjustment(UINT8_MAX, UINT8_MAX, UINT8_MAX); } -RgbChannelAdjustment::RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB) +RgbChannelAdjustment::RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB, QString channelName) + : _channelName(channelName) + , _log(Logger::getInstance(channelName)) { setAdjustment(adjustR, adjustG, adjustB); } @@ -75,6 +79,7 @@ uint8_t RgbChannelAdjustment::getAdjustmentB(uint8_t inputB) const void RgbChannelAdjustment::initializeMapping() { + Debug(_log, "initialize mapping with %d,%d,%d", _adjust[RED], _adjust[GREEN], _adjust[BLUE]); // initialize linear mapping for (unsigned channel=0; channel<3; channel++) for (unsigned idx=0; idx<=UINT8_MAX; idx++) diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 739df7d5..7d0530c1 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -478,6 +478,22 @@ void JsonConnection::setAdjustment( yellow.append(yellowAdjustment.blue()); adjust["yellowAdjust"] = yellow; } + if (whiteAdjustment.isValid()) + { + QJsonArray white; + white.append(whiteAdjustment.red()); + white.append(whiteAdjustment.green()); + white.append(whiteAdjustment.blue()); + adjust["whiteAdjust"] = white; + } + if (blackAdjustment.isValid()) + { + QJsonArray black; + black.append(blackAdjustment.red()); + black.append(blackAdjustment.green()); + black.append(blackAdjustment.blue()); + adjust["blackAdjust"] = black; + } if (brightnessMin != nullptr) { adjust["brightnessMin"] = *brightnessMin;