diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json index a1dbbb6e..55ca5314 100644 --- a/assets/webconfig/i18n/de.json +++ b/assets/webconfig/i18n/de.json @@ -1,13 +1,13 @@ { - "@metadata": { - "authors": [ - "brindosch" - ], - "project" : "Hyperion WebUI", - "locale": "de", + "@metadata": { + "authors": [ + "brindosch" + ], + "project" : "Hyperion WebUI", + "locale": "de", "last-updated": "2016-11-30", - "message-documentation": "qqq" - }, + "message-documentation": "qqq" + }, "general_webui_title" : "Hyperion - Web Konfiguration", "general_country_de" : "Deutschland", "general_country_us" : "Amerika", @@ -422,7 +422,8 @@ "edt_conf_color_gammaGreen_expl" : "Gamma von grün.", "edt_conf_color_gammaBlue_title" : "Gamma blau", "edt_conf_color_gammaBlue_expl" : "Gamma von blau", - "edt_conf_color_brightnessMin_title" : "Minimale Helligkeit", + "edt_conf_color_backlightThreshold_title" : "Minimale Helligkeit", + "edt_conf_color_backlightColored_title" : "Farbige Hintergrundbeleuchtung", "edt_conf_color_brightnessMin_expl" : "Auch als Hintergrundhelligkeit genutzt.", "edt_conf_color_brightness_title" : "Maximale Helligkeit", "edt_conf_color_brightness_expl" : "Zwischen 0.0 und 0.5 ist die Helligkeit linearisiert. Von 0.5 bis 1.0 wird cyan, magenta und gelb bis zu 2x heller und weiß bis zu 3x.", diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 6c74f48e..947bd50c 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -1,13 +1,13 @@ { - "@metadata": { - "authors": [ - "brindosch" - ], - "project" : "Hyperion WebUI", - "locale": "en", + "@metadata": { + "authors": [ + "brindosch" + ], + "project" : "Hyperion WebUI", + "locale": "en", "last-updated": "2016-11-30", - "message-documentation": "qqq.json" - }, + "message-documentation": "qqq.json" + }, "general_webui_title" : "Hyperion - Web Configuration", "general_country_de" : "Germany", "general_country_us" : "United States", @@ -422,7 +422,8 @@ "edt_conf_color_gammaGreen_expl" : "The gamma of green.", "edt_conf_color_gammaBlue_title" : "gamma blue", "edt_conf_color_gammaBlue_expl" : "The gamma of blue.", - "edt_conf_color_brightnessMin_title" : "minimal brightness", + "edt_conf_color_backlightThreshold_title" : "backlight threshold", + "edt_conf_color_backlightColored_title" : "Colored backlight", "edt_conf_color_brightnessMin_expl" : "The minimum amount of brightness (backlight).", "edt_conf_color_brightness_title" : "maximal brightness", "edt_conf_color_brightness_expl" : "From 0.0 to 0.5 the brightness is linearised, from 0.5 to 1.0 cyan, magenta, yellow is up to 2x brighter and white 3x.", diff --git a/assets/webconfig/js/wizard.js b/assets/webconfig/js/wizard.js index b983215f..1f856270 100644 --- a/assets/webconfig/js/wizard.js +++ b/assets/webconfig/js/wizard.js @@ -347,7 +347,7 @@ $(document).ready( function() { } if(step == 10) { - updateWEditor(["brightnessMin"]); + updateWEditor(["backlightThreshold"]); h = $.i18n('wiz_cc_minBright'); if(withKodi) { diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index bb32fdc6..4c31cc0c 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -49,7 +49,8 @@ /// * 'gammaRed'/'gammaGreen'/'gammaBlue' : Gamma value for each channel /// * 'id' : The unique identifier of the channel adjustments (eg 'device_1') /// * 'id' : The unique identifier of the channel adjustments (eg 'device_1') - /// * 'brightnessMin' : Minimum brightness (backlight) + /// * 'backlightThreshold' : Minimum brightness (backlight) + /// * 'backlightColored' : backlight with color, instead of white /// * 'brightness' : Between 0.0-0.5 the brightness is linearized (white is as bright as red, is as bright as yellow). /// Between 0.5-1.0 the linearization reduces slowly until it's gone with 1.0 (white is 3x brighter than red, yellow is 2x brighter than red) "color" : @@ -71,7 +72,8 @@ "gammaRed" : 1.0, "gammaGreen" : 1.0, "gammaBlue" : 1.0, - "brightnessMin" : 0.0, + "backlightThreshold" : 0.0, + "backlightColored" : false, "brightness" : 0.5 } ] diff --git a/config/hyperion.config.json.default b/config/hyperion.config.json.default index fb3de8c9..27630c54 100644 --- a/config/hyperion.config.json.default +++ b/config/hyperion.config.json.default @@ -38,7 +38,8 @@ "gammaRed" : 1.0, "gammaGreen" : 1.0, "gammaBlue" : 1.0, - "brightnessMin" : 0.0, + "backlightThreshold" : 0.0, + "backlightColored" : false, "brightness" : 0.75 } ] diff --git a/include/commandline/DoubleOption.h b/include/commandline/DoubleOption.h index 9eb3f924..b7daa012 100644 --- a/include/commandline/DoubleOption.h +++ b/include/commandline/DoubleOption.h @@ -1,5 +1,4 @@ -#ifndef HYPERION_DOUBLECOMMANDLINEOPTION_H -#define HYPERION_DOUBLECOMMANDLINEOPTION_H +#pragma once #include #include "ValidatorOption.h" @@ -9,32 +8,38 @@ namespace commandline class DoubleOption: public ValidatorOption { -protected: - double _double; public: - DoubleOption(const QString &name, - const QString &description = QString(), - const QString &valueName = QString(), - const QString &defaultValue = QString(), - double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) - : ValidatorOption(name, description, valueName, defaultValue) - { setValidator(new QDoubleValidator(minimum, maximum, decimals)); } - DoubleOption(const QStringList &names, - const QString &description = QString(), - const QString &valueName = QString(), - const QString &defaultValue = QString(), - double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) - : ValidatorOption(names, description, valueName, defaultValue) - { setValidator(new QDoubleValidator(minimum, maximum, decimals)); } - DoubleOption(const QCommandLineOption &other, - double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) - : ValidatorOption(other) - { setValidator(new QDoubleValidator(minimum, maximum, decimals)); } + DoubleOption(const QString &name, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) + : ValidatorOption(name, description, valueName, defaultValue) + { + setValidator(new QDoubleValidator(minimum, maximum, decimals)); + } - double getDouble(Parser &parser, bool *ok = 0); - double *getDoublePtr(Parser &parser, bool *ok = 0); + DoubleOption(const QStringList &names, + const QString &description = QString(), + const QString &valueName = QString(), + const QString &defaultValue = QString(), + double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) + : ValidatorOption(names, description, valueName, defaultValue) + { + setValidator(new QDoubleValidator(minimum, maximum, decimals)); + } + + DoubleOption(const QCommandLineOption &other, double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000) + : ValidatorOption(other) + { + setValidator(new QDoubleValidator(minimum, maximum, decimals)); + } + + double getDouble(Parser &parser, bool *ok = 0); + double *getDoublePtr(Parser &parser, bool *ok = 0); + +protected: + double _double; }; } - -#endif //HYPERION_DOUBLECOMMANDLINEOPTION_H diff --git a/include/commandline/SwitchOption.h b/include/commandline/SwitchOption.h index 06763661..6133e3bd 100644 --- a/include/commandline/SwitchOption.h +++ b/include/commandline/SwitchOption.h @@ -1,5 +1,4 @@ -#ifndef HYPERION_SWITCHCOMMANDLINEOPTION_H -#define HYPERION_SWITCHCOMMANDLINEOPTION_H +#pragma once #include #include "Option.h" @@ -10,10 +9,8 @@ namespace commandline template class SwitchOption: public Option { -protected: - QMap _switches; public: - SwitchOption(const QString &name, + SwitchOption(const QString &name, const QString &description = QString(), const QString &valueName = QString(), const QString &defaultValue = QString(), @@ -38,8 +35,9 @@ public: void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;} void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());} T & switchValue(Parser & parser){return _switches[value(parser).toLower()];} + +protected: + QMap _switches; }; } - -#endif //HYPERION_SWITCHCOMMANDLINEOPTION_H diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index bc052b8e..230514b3 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -368,4 +368,6 @@ private: int _ledMAppingType; int _configVersionId; + + hyperion::Components _prevCompId; }; diff --git a/include/utils/RgbTransform.h b/include/utils/RgbTransform.h index cf3075a1..32523362 100644 --- a/include/utils/RgbTransform.h +++ b/include/utils/RgbTransform.h @@ -20,10 +20,11 @@ public: /// @param gammaR The used red gamma /// @param gammaG The used green gamma /// @param gammab The used blue gamma - /// @param brightnessLow The used lower brightness + /// @param backlightThreshold The used lower brightness + /// @param backlightColored use color in backlight /// @param brightnessHigh The used higher brightness /// - RgbTransform(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh); + RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh); /// /// Destructor @@ -39,19 +40,34 @@ public: /// @return The current blue gamma value double getGammaB() const; - /// @param gamma New gamma value + /// @param gammaR New red gamma value + /// @param gammaG New green gamma value + /// @param gammaB New blue gamma value void setGamma(double gammaR,double gammaG=-1, double gammaB=-1); /// @return The current lower brightness - double getBrightnessMin() const; + double getBacklightThreshold() const; - /// @param gamma New lower brightness - void setBrightnessMin(double brightness); + /// @param backlightThreshold New lower brightness + void setBacklightThreshold(double backlightThreshold); - /// @return The current lower brightness + /// @return The current state + bool getBacklightColored() const; + + /// @param backlightColored en/disable colored backlight + void setBacklightColored(bool backlightColored); + + /// @return return state of backlight + bool getBackLightEnabled() const; + + /// @param enable en/disable backlight + void setBackLightEnabled(bool enable); + + + /// @return The current brightness double getBrightness() const; - /// @param gamma New lower brightness + /// @param brightness New brightness void setBrightness(double brightness); /// @@ -72,15 +88,17 @@ private: /// @param gammaR The used red gamma /// @param gammaG The used green gamma /// @param gammab The used blue gamma - /// @param brightnessLow The used lower brightness + /// @param backlightThreshold The used lower brightness + /// @param backlightColored en/disable color in backlight /// @param brightnessHigh The used higher brightness /// - void init(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh); + void init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh); /// (re)-initilize the color mapping void initializeMapping(); /// The saturation gain - double _brightnessLow; + double _backlightThreshold; + bool _backlightColored; double _brightnessHigh; double _sumBrightnessLow; double _sumBrightnessHigh; @@ -93,4 +111,6 @@ private: uint8_t _mappingR[256]; uint8_t _mappingG[256]; uint8_t _mappingB[256]; + + bool _backLightEnabled; }; diff --git a/libsrc/commandline/ColorOption.cpp b/libsrc/commandline/ColorOption.cpp index 32863fad..512b2b9f 100644 --- a/libsrc/commandline/ColorOption.cpp +++ b/libsrc/commandline/ColorOption.cpp @@ -6,25 +6,27 @@ using namespace commandline; bool ColorOption::validate(Parser & parser, QString & value) { - // Check if we can create the color by name - _color = QColor(value); - if (_color.isValid()) { - return true; - } + // Check if we can create the color by name + _color = QColor(value); + if (_color.isValid()) + { + return true; + } - // check if we can create the color by hex RRGGBB getColors - _color = QColor(QString("#%1").arg(value)); - if (_color.isValid()) { - return true; - } + // check if we can create the color by hex RRGGBB getColors + _color = QColor(QString("#%1").arg(value)); + if (_color.isValid()) + { + return true; + } - if(!parser.isSet(*this)){ - // Return true if no value is available - return true; - } + if(!parser.isSet(*this)) + { + // Return true if no value is available + return true; + } - QStringList error; - _error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- ")); + _error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- ")); - return false; + return false; } diff --git a/libsrc/commandline/ColorsOption.cpp b/libsrc/commandline/ColorsOption.cpp index b7f81bd7..f32cfed8 100644 --- a/libsrc/commandline/ColorsOption.cpp +++ b/libsrc/commandline/ColorsOption.cpp @@ -6,32 +6,36 @@ using namespace commandline; bool ColorsOption::validate(Parser & parser, QString & value) { - // Clear any old results - _colors.clear(); + // Clear any old results + _colors.clear(); - // Check if we can create the color by name - QColor color(value); - if (color.isValid()) { - _colors.push_back(color); - return true; - } + // Check if we can create the color by name + QColor color(value); + if (color.isValid()) + { + _colors.push_back(color); + return true; + } - // check if we can create the color by hex RRGGBB getColors - QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption); - QRegularExpressionMatch match = hexRe.match(value); - if(match.hasMatch()) { - Q_FOREACH(const QString m, match.capturedTexts()){ - _colors.push_back(QColor(QString("#%1").arg(m))); - } - return true; - } + // check if we can create the color by hex RRGGBB getColors + QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption); + QRegularExpressionMatch match = hexRe.match(value); + if(match.hasMatch()) + { + Q_FOREACH(const QString m, match.capturedTexts()) + { + _colors.push_back(QColor(QString("#%1").arg(m))); + } + return true; + } - if(!parser.isSet(*this)){ + if(!parser.isSet(*this)) + { // Return true if no value is available return true; } - _error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- ")); + _error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- ")); - return false; + return false; } diff --git a/libsrc/commandline/DoubleOption.cpp b/libsrc/commandline/DoubleOption.cpp index 532df096..09f77248 100644 --- a/libsrc/commandline/DoubleOption.cpp +++ b/libsrc/commandline/DoubleOption.cpp @@ -5,16 +5,17 @@ using namespace commandline; double DoubleOption::getDouble(Parser &parser, bool *ok) { - _double = value(parser).toDouble(ok); - return _double; + _double = value(parser).toDouble(ok); + return _double; } double *DoubleOption::getDoublePtr(Parser &parser, bool *ok) { - if (parser.isSet(this)) { - getDouble(parser, ok); - return &_double; - } else { - return nullptr; - } + if (parser.isSet(this)) + { + getDouble(parser, ok); + return &_double; + } + + return nullptr; } diff --git a/libsrc/commandline/ImageOption.cpp b/libsrc/commandline/ImageOption.cpp index 77933176..450229ec 100644 --- a/libsrc/commandline/ImageOption.cpp +++ b/libsrc/commandline/ImageOption.cpp @@ -4,7 +4,8 @@ using namespace commandline; bool ImageOption::validate(Parser & parser, QString & value) { - if(value.size()){ + if(value.size()) + { _image = QImage(value); if (_image.isNull()) @@ -12,7 +13,7 @@ bool ImageOption::validate(Parser & parser, QString & value) _error = QString("File %1 could not be opened as image").arg(value); return false; } - } + } - return true; + return true; } diff --git a/libsrc/commandline/IntOption.cpp b/libsrc/commandline/IntOption.cpp index e034fb0c..1bde9911 100644 --- a/libsrc/commandline/IntOption.cpp +++ b/libsrc/commandline/IntOption.cpp @@ -5,16 +5,16 @@ using namespace commandline; int IntOption::getInt(Parser &parser, bool *ok, int base) { - _int = value(parser).toInt(ok, base); - return _int; + _int = value(parser).toInt(ok, base); + return _int; } int *IntOption::getIntPtr(Parser &parser, bool *ok, int base) { - if (parser.isSet(this)) { - getInt(parser, ok, base); - return &_int; - } else { - return nullptr; - } + if (parser.isSet(this)) + { + getInt(parser, ok, base); + return &_int; + } + return nullptr; } diff --git a/libsrc/commandline/Option.cpp b/libsrc/commandline/Option.cpp index abc7892a..aa045bf3 100644 --- a/libsrc/commandline/Option.cpp +++ b/libsrc/commandline/Option.cpp @@ -6,26 +6,26 @@ using namespace commandline; bool Option::validate(Parser & parser, QString &value) { /* By default everything is accepted */ - return true; + return true; } QString Option::value(Parser &parser) { - return parser.value(*this); + return parser.value(*this); } std::string Option::getStdString(Parser &parser) { - return value(parser).toStdString(); + return value(parser).toStdString(); } std::wstring Option::getStdWString(Parser &parser) { - return value(parser).toStdWString(); + return value(parser).toStdWString(); } const char* Option::getCString(Parser &parser) { - return value(parser).toLocal8Bit().constData(); + return value(parser).toLocal8Bit().constData(); } diff --git a/libsrc/commandline/Parser.cpp b/libsrc/commandline/Parser.cpp index c09c3449..e90fd429 100644 --- a/libsrc/commandline/Parser.cpp +++ b/libsrc/commandline/Parser.cpp @@ -6,85 +6,88 @@ using namespace commandline; bool Parser::parse(const QStringList &arguments) { - if (!_parser.parse(arguments)) { - return false; - } + if (!_parser.parse(arguments)) + { + return false; + } - Q_FOREACH(Option * option, _options) { - QString value = this->value(*option); - if (!option->validate(*this, value)) { - const QString error = option->getError(); - if (error.size()) { - _errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error); - } - else { - _errorText = tr("%1 is not a valid option for %2").arg(value, option->name()); - } - return false; + Q_FOREACH(Option * option, _options) + { + QString value = this->value(*option); + if (!option->validate(*this, value)) { + const QString error = option->getError(); + if (error.size()) { + _errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error); } - } - return true; + else + { + _errorText = tr("%1 is not a valid option for %2").arg(value, option->name()); + } + return false; + } + } + return true; } void Parser::process(const QStringList &arguments) { - _parser.process(arguments); - if (!parse(arguments)) { - + _parser.process(arguments); + if (!parse(arguments)) + { fprintf(stdout, "%s", qPrintable(tr("Error: %1").arg(_errorText))); - showHelp(EXIT_FAILURE); - } + showHelp(EXIT_FAILURE); + } } void Parser::process(const QCoreApplication &app) { - Q_UNUSED(app); - process(QCoreApplication::arguments()); + Q_UNUSED(app); + process(QCoreApplication::arguments()); } QString Parser::errorText() const { - if (_errorText.size()) { - return _errorText; - } - else { - return _parser.errorText(); - } + return (_errorText.size()) ? _errorText : _parser.errorText(); } bool Parser::addOption(Option &option) { - return addOption(&option); + return addOption(&option); } bool Parser::addOption(Option * const option) { - _options[option->name()] = option; - return _parser.addOption(*option); + _options[option->name()] = option; + return _parser.addOption(*option); } + QStringList Parser::_getNames(const char shortOption, const QString longOption) { QStringList names; - if (shortOption != 0x0) { + if (shortOption != 0x0) + { names << QString(shortOption); } - if (longOption.size()) { + if (longOption.size()) + { names << longOption; } return names; } + QString Parser::_getDescription(const QString description, const QString default_) { /* Add the translations if available */ QString formattedDescription(tr(qPrintable(description))); /* Fill in the default if needed */ - if (default_.size()) { - if(!formattedDescription.contains("%1")){ + if (default_.size()) + { + if(!formattedDescription.contains("%1")) + { formattedDescription += " [default: %1]"; } formattedDescription = formattedDescription.arg(default_); } return formattedDescription; } - diff --git a/libsrc/commandline/ValidatorOption.cpp b/libsrc/commandline/ValidatorOption.cpp index 9dfc9fca..fd35568f 100644 --- a/libsrc/commandline/ValidatorOption.cpp +++ b/libsrc/commandline/ValidatorOption.cpp @@ -5,21 +5,22 @@ using namespace commandline; bool ValidatorOption::validate(Parser & parser, QString & value) { - if (parser.isSet(*this) || !defaultValues().empty()) { + if (parser.isSet(*this) || !defaultValues().empty()) + { int pos = 0; validator->fixup(value); return validator->validate(value, pos) == QValidator::Acceptable; - } else { - return true; } + return true; } const QValidator *ValidatorOption::getValidator() const { - return validator; -} -void ValidatorOption::setValidator(const QValidator *validator) -{ - ValidatorOption::validator = validator; + return validator; +} + +void ValidatorOption::setValidator(const QValidator *validator) +{ + ValidatorOption::validator = validator; } diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index bfa61805..cdc327af 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -158,13 +158,14 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt RgbTransform* Hyperion::createRgbTransform(const QJsonObject& colorConfig) { - const double brightnessMin = colorConfig["brightnessMin"].toDouble(0.0); + const double backlightThreshold = colorConfig["backlightThreshold"].toDouble(0.0); + const bool backlightColored = colorConfig["backlightColored"].toBool(false); const double brightness = colorConfig["brightness"].toDouble(0.5); const double gammaR = colorConfig["gammaRed"].toDouble(1.0); const double gammaG = colorConfig["gammaGreen"].toDouble(1.0); const double gammaB = colorConfig["gammaBlue"].toDouble(1.0); - RgbTransform* transform = new RgbTransform(gammaR, gammaG, gammaB, brightnessMin, brightness); + RgbTransform* transform = new RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, brightness); return transform; } @@ -392,10 +393,10 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile) , _timer() , _log(CORE_LOGGER) , _hwLedCount(_ledString.leds().size()) - , _sourceAutoSelectEnabled(true) , _configHash() , _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"])) + , _prevCompId(hyperion::COMP_INVALID) { registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY); @@ -718,6 +719,12 @@ void Hyperion::update() if ( priority < PriorityMuxer::LOWEST_PRIORITY) { + if (priorityInfo.componentId != _prevCompId) + { + bool backlightEnabled = (priorityInfo.componentId != hyperion::COMP_COLOR && priorityInfo.componentId != hyperion::COMP_EFFECT); + _raw2ledAdjustment->setBacklightEnabled(backlightEnabled); + _prevCompId = priorityInfo.componentId; + } _raw2ledAdjustment->applyAdjustment(_ledBuffer); } diff --git a/libsrc/hyperion/MultiColorAdjustment.cpp b/libsrc/hyperion/MultiColorAdjustment.cpp index 9c5ef0a4..b1662ba6 100644 --- a/libsrc/hyperion/MultiColorAdjustment.cpp +++ b/libsrc/hyperion/MultiColorAdjustment.cpp @@ -51,11 +51,11 @@ bool MultiColorAdjustment::verifyAdjustments() const Error(_log, "No adjustment set for %d", iLed); return false; } - if (adjustment->_rgbTransform.getBrightness() <= adjustment->_rgbTransform.getBrightnessMin() ) + if (adjustment->_rgbTransform.getBrightness() <= adjustment->_rgbTransform.getBacklightThreshold() ) { - adjustment->_rgbTransform.setBrightnessMin(0); + adjustment->_rgbTransform.setBacklightThreshold(0.0); adjustment->_rgbTransform.setBrightness(0.5); - Warning(_log, "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. (setBacklightThreshold is bigger then brightness)", iLed); } } return true; @@ -81,6 +81,15 @@ ColorAdjustment* MultiColorAdjustment::getAdjustment(const std::string& id) return nullptr; } +void MultiColorAdjustment::setBacklightEnabled(bool enable) +{ + for (ColorAdjustment* adjustment : _adjustment) + { + adjustment->_rgbTransform.setBackLightEnabled(enable); + } +} + + void MultiColorAdjustment::applyAdjustment(std::vector& ledColors) { const size_t itCnt = std::min(_ledAdjustments.size(), ledColors.size()); diff --git a/libsrc/hyperion/MultiColorAdjustment.h b/libsrc/hyperion/MultiColorAdjustment.h index 5d9db94c..eaeb94ba 100644 --- a/libsrc/hyperion/MultiColorAdjustment.h +++ b/libsrc/hyperion/MultiColorAdjustment.h @@ -30,6 +30,8 @@ public: bool verifyAdjustments() const; + void setBacklightEnabled(bool enable); + /// /// Returns the identifier of all the unique ColorAdjustment /// diff --git a/libsrc/hyperion/schemas/hyperion.schema-2.json b/libsrc/hyperion/schemas/hyperion.schema-2.json index dbaf6246..adcf009e 100644 --- a/libsrc/hyperion/schemas/hyperion.schema-2.json +++ b/libsrc/hyperion/schemas/hyperion.schema-2.json @@ -271,10 +271,10 @@ "maxItems" : 3, "propertyOrder" : 10 }, - "brightnessMin" : + "backlightThreshold" : { "type" : "number", - "title" : "edt_conf_color_brightnessMin_title", + "title" : "edt_conf_color_backlightThreshold_title", "required" : true, "minimum" : 0.0, "maximum": 1.0, @@ -282,6 +282,14 @@ "step" : 0.05, "propertyOrder" : 11 }, + "backlightColored" : + { + "type" : "boolean", + "title" : "edt_conf_color_backlightColored_title", + "required" : true, + "default" : false, + "propertyOrder" : 12 + }, "brightness" : { "type" : "number", @@ -291,7 +299,7 @@ "maximum": 1.0, "default" : 1.0, "step" : 0.05, - "propertyOrder" : 12 + "propertyOrder" : 13 }, "gammaRed" : { @@ -302,7 +310,7 @@ "maximum": 100.0, "default" : 1.0, "step" : 0.1, - "propertyOrder" : 13 + "propertyOrder" : 14 }, "gammaGreen" : { @@ -313,7 +321,7 @@ "maximum": 100.0, "default" : 1.0, "step" : 0.1, - "propertyOrder" : 14 + "propertyOrder" : 15 }, "gammaBlue" : { @@ -324,7 +332,7 @@ "maximum": 100.0, "default" : 1.0, "step" : 0.1, - "propertyOrder" : 15 + "propertyOrder" : 16 } }, "additionalProperties" : false diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 740f2549..eab44f77 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -731,11 +731,12 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt yellowAdjust.append(colorAdjustment->_rgbYellowAdjustment.getAdjustmentB()); adjustment.insert("yellow", yellowAdjust); - adjustment["brightnessMin"] = colorAdjustment->_rgbTransform.getBrightnessMin(); + adjustment["backlightThreshold"] = colorAdjustment->_rgbTransform.getBacklightThreshold(); + adjustment["backlightColored"] = colorAdjustment->_rgbTransform.getBacklightColored(); adjustment["brightness"] = colorAdjustment->_rgbTransform.getBrightness(); - adjustment["gammaRed"] = colorAdjustment->_rgbTransform.getGammaR(); + adjustment["gammaRed"] = colorAdjustment->_rgbTransform.getGammaR(); adjustment["gammaGreen"] = colorAdjustment->_rgbTransform.getGammaG(); - adjustment["gammaBlue"] = colorAdjustment->_rgbTransform.getGammaB(); + adjustment["gammaBlue"] = colorAdjustment->_rgbTransform.getGammaB(); adjustmentArray.append(adjustment); } @@ -913,9 +914,13 @@ void JsonClientConnection::handleAdjustmentCommand(const QJsonObject& message, c colorAdjustment->_rgbTransform.setGamma(colorAdjustment->_rgbTransform.getGammaR(), colorAdjustment->_rgbTransform.getGammaG(), adjustment["gammaBlue"].toDouble()); } - if (adjustment.contains("brightnessMin")) + if (adjustment.contains("backlightThreshold")) { - colorAdjustment->_rgbTransform.setBrightnessMin(adjustment["brightnessMin"].toDouble()); + colorAdjustment->_rgbTransform.setBacklightThreshold(adjustment["backlightThreshold"].toDouble()); + } + if (adjustment.contains("backlightColored")) + { + colorAdjustment->_rgbTransform.setBacklightColored(adjustment["backlightColored"].toBool()); } if (adjustment.contains("brightness")) { diff --git a/libsrc/jsonserver/JsonClientConnection.h b/libsrc/jsonserver/JsonClientConnection.h index 10b37fdb..5adc067c 100644 --- a/libsrc/jsonserver/JsonClientConnection.h +++ b/libsrc/jsonserver/JsonClientConnection.h @@ -351,13 +351,13 @@ private: // masks for fields in the basic header static uint8_t const BHB0_OPCODE = 0x0F; - static uint8_t const BHB0_RSV3 = 0x10; - static uint8_t const BHB0_RSV2 = 0x20; - static uint8_t const BHB0_RSV1 = 0x40; - static uint8_t const BHB0_FIN = 0x80; + static uint8_t const BHB0_RSV3 = 0x10; + static uint8_t const BHB0_RSV2 = 0x20; + static uint8_t const BHB0_RSV1 = 0x40; + static uint8_t const BHB0_FIN = 0x80; static uint8_t const BHB1_PAYLOAD = 0x7F; - static uint8_t const BHB1_MASK = 0x80; + static uint8_t const BHB1_MASK = 0x80; static uint8_t const payload_size_code_16bit = 0x7E; // 126 static uint8_t const payload_size_code_64bit = 0x7F; // 127 diff --git a/libsrc/jsonserver/schema/schema-adjustment.json b/libsrc/jsonserver/schema/schema-adjustment.json index cc71dea8..3d983dc0 100644 --- a/libsrc/jsonserver/schema/schema-adjustment.json +++ b/libsrc/jsonserver/schema/schema-adjustment.json @@ -124,12 +124,16 @@ "minimum" : 0.0, "maximum" : 100.0 }, - "brightnessMin" : { + "backlightThreshold" : { "type" : "number", "required" : false, "minimum" : 0.0, "maximum" : 1.0 }, + "backlightColored" : { + "type" : "boolean", + "required" : false + }, "brightness" : { "type" : "number", "required" : false, diff --git a/libsrc/leddevice/LedDeviceUdpE131.h b/libsrc/leddevice/LedDeviceUdpE131.h index fe5f63c3..4c153822 100644 --- a/libsrc/leddevice/LedDeviceUdpE131.h +++ b/libsrc/leddevice/LedDeviceUdpE131.h @@ -82,17 +82,17 @@ typedef union } e131_packet_t; /* defined parameters from http://tsp.esta.org/tsp/documents/docs/BSR_E1-31-20xx_CP-2014-1009r2.pdf */ -#define VECTOR_ROOT_E131_DATA 0x00000004 -#define VECTOR_ROOT_E131_EXTENDED 0x00000008 -#define VECTOR_DMP_SET_PROPERTY 0x02 -#define VECTOR_E131_DATA_PACKET 0x00000002 -#define VECTOR_E131_EXTENDED_SYNCHRONIZATION 0x00000001 -#define VECTOR_E131_EXTENDED_DISCOVERY 0x00000002 +#define VECTOR_ROOT_E131_DATA 0x00000004 +#define VECTOR_ROOT_E131_EXTENDED 0x00000008 +#define VECTOR_DMP_SET_PROPERTY 0x02 +#define VECTOR_E131_DATA_PACKET 0x00000002 +#define VECTOR_E131_EXTENDED_SYNCHRONIZATION 0x00000001 +#define VECTOR_E131_EXTENDED_DISCOVERY 0x00000002 #define VECTOR_UNIVERSE_DISCOVERY_UNIVERSE_LIST 0x00000001 -#define E131_E131_UNIVERSE_DISCOVERY_INTERVAL 10 // seconds -#define E131_NETWORK_DATA_LOSS_TIMEOUT 2500 // milli econds -#define E131_DISCOVERY_UNIVERSE 64214 -#define DMX_MAX 512 // 512 usable slots +#define E131_E131_UNIVERSE_DISCOVERY_INTERVAL 10 // seconds +#define E131_NETWORK_DATA_LOSS_TIMEOUT 2500 // milli econds +#define E131_DISCOVERY_UNIVERSE 64214 +#define DMX_MAX 512 // 512 usable slots /// /// Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets diff --git a/libsrc/leddevice/LedDeviceUdpH801.cpp b/libsrc/leddevice/LedDeviceUdpH801.cpp index bd31ba3c..781878a6 100644 --- a/libsrc/leddevice/LedDeviceUdpH801.cpp +++ b/libsrc/leddevice/LedDeviceUdpH801.cpp @@ -11,7 +11,8 @@ bool LedDeviceUdpH801::init(const QJsonObject &deviceConfig) /* The H801 port is fixed */ _LatchTime_ns = 10000000; _port = 30977; - ProviderUdp::init(deviceConfig, "255.255.255.255"); + _defaultHost = "255.255.255.255"; + ProviderUdp::init(deviceConfig); _ids.clear(); QJsonArray lArray = deviceConfig["lightIds"].toArray(); diff --git a/libsrc/leddevice/ProviderUdp.cpp b/libsrc/leddevice/ProviderUdp.cpp index 59ca7f28..b3d685a2 100644 --- a/libsrc/leddevice/ProviderUdp.cpp +++ b/libsrc/leddevice/ProviderUdp.cpp @@ -19,6 +19,7 @@ ProviderUdp::ProviderUdp() : LedDevice() , _LatchTime_ns(-1) , _port(1) + , _defaultHost("127.0.0.1") { _udpSocket = new QUdpSocket(); } @@ -28,11 +29,11 @@ ProviderUdp::~ProviderUdp() _udpSocket->close(); } -bool ProviderUdp::init(const QJsonObject &deviceConfig, std::string defaultHost) +bool ProviderUdp::init(const QJsonObject &deviceConfig) { LedDevice::init(deviceConfig); - QString host = deviceConfig["host"].toString(QString::fromStdString(defaultHost)); + QString host = deviceConfig["host"].toString(_defaultHost); if (_address.setAddress(host) ) { diff --git a/libsrc/leddevice/ProviderUdp.h b/libsrc/leddevice/ProviderUdp.h index cd18c5c7..f0e2a818 100644 --- a/libsrc/leddevice/ProviderUdp.h +++ b/libsrc/leddevice/ProviderUdp.h @@ -27,7 +27,7 @@ public: /// /// @param deviceConfig the json device config /// @return true if success - bool init(const QJsonObject &deviceConfig, std::string defaultHost="127.0.0.1"); + virtual bool init(const QJsonObject &deviceConfig); /// /// Opens and configures the output device @@ -55,4 +55,5 @@ protected: QUdpSocket * _udpSocket; QHostAddress _address; quint16 _port; + QString _defaultHost; }; diff --git a/libsrc/utils/Logger.cpp b/libsrc/utils/Logger.cpp index 95108d22..76e8e74e 100644 --- a/libsrc/utils/Logger.cpp +++ b/libsrc/utils/Logger.cpp @@ -11,7 +11,6 @@ static const char * LogLevelStrings[] = { "", "DEBUG", "INFO", "WARNING", "ERR static const int LogLevelSysLog[] = { LOG_DEBUG, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERR }; static unsigned int loggerCount = 0; static unsigned int loggerId = 0; -static const int loggerMaxMsgBufferSize = 50; std::map *Logger::LoggerMap = nullptr; Logger::LogLevel Logger::GLOBAL_MIN_LOG_LEVEL = Logger::UNSET; diff --git a/libsrc/utils/RgbTransform.cpp b/libsrc/utils/RgbTransform.cpp index b2878e35..256cabb5 100644 --- a/libsrc/utils/RgbTransform.cpp +++ b/libsrc/utils/RgbTransform.cpp @@ -5,18 +5,20 @@ RgbTransform::RgbTransform() { - init(1.0, 1.0, 1.0, 0.0, 1.0); + init(1.0, 1.0, 1.0, 0.0, false, 1.0); } -RgbTransform::RgbTransform(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh) +RgbTransform::RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh) { - init(gammaR, gammaG, gammaB, brightnessLow, brightnessHigh); + init(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, brightnessHigh); } -void RgbTransform::init(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh) +void RgbTransform::init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh) { + _backLightEnabled = true; setGamma(gammaR,gammaG,gammaB); - setBrightnessMin(brightnessLow); + setBacklightThreshold(backlightThreshold); + setBacklightColored(backlightColored); setBrightness(brightnessHigh); initializeMapping(); } @@ -59,15 +61,35 @@ void RgbTransform::initializeMapping() } -double RgbTransform::getBrightnessMin() const +double RgbTransform::getBacklightThreshold() const { - return _brightnessLow; + return _backlightThreshold; } -void RgbTransform::setBrightnessMin(double brightness) +void RgbTransform::setBacklightThreshold(double backlightThreshold) { - _brightnessLow = brightness; - _sumBrightnessLow = 765.0 * ((std::pow(2.0,brightness*2)-1) / 3.0); + _backlightThreshold = backlightThreshold; + _sumBrightnessLow = 765.0 * ((std::pow(2.0,backlightThreshold*2)-1) / 3.0); +} + +bool RgbTransform::getBacklightColored() const +{ + return _backlightColored; +} + +void RgbTransform::setBacklightColored(bool backlightColored) +{ + _backlightColored = backlightColored; +} + +bool RgbTransform::getBackLightEnabled() const +{ + return _backLightEnabled; +} + +void RgbTransform::setBackLightEnabled(bool enable) +{ + _backLightEnabled = enable; } double RgbTransform::getBrightness() const @@ -90,25 +112,38 @@ void RgbTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue) //std::cout << (int)red << " " << (int)green << " " << (int)blue << " => "; // apply brightnesss - if (red ==0) red = 1; - if (green==0) green = 1; - if (blue ==0) blue = 1; - int rgbSum = red+green+blue; - if (rgbSum > _sumBrightnessHigh) + if (_sumBrightnessHigh > 0 && rgbSum > _sumBrightnessHigh) { double cH = _sumBrightnessHigh / rgbSum; red *= cH; green *= cH; blue *= cH; } - else if (rgbSum < _sumBrightnessLow) + else if ( _backLightEnabled && _sumBrightnessLow>0 && rgbSum < _sumBrightnessLow) { - double cL = _sumBrightnessLow / rgbSum; - red *= cL; - green *= cL; - blue *= cL; + if (_backlightColored) + { + if (rgbSum == 0) + { + if (red ==0) red = 1; + if (green==0) green = 1; + if (blue ==0) blue = 1; + rgbSum = red+green+blue; + } + double cL =std::min((int)(_sumBrightnessLow /rgbSum), 255); + + red *= cL; + green *= cL; + blue *= cL; + } + else + { + red = std::min((int)(_sumBrightnessLow/3.0), 255); + green = red; + blue = red; + } } - //std::cout << (int)red << " " << (int)green << " " << (int)blue << std::endl; + //std::cout << _sumBrightnessLow << " " << (int)red << " " << (int)green << " " << (int)blue << std::endl; } diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 61ebc5f6..9f93a539 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -414,7 +414,8 @@ void JsonConnection::setAdjustment( double *gammaR, double *gammaG, double *gammaB, - double *brightnessMin, + double *backlightThreshold, + int *backlightColored, double *brightness) { qDebug() << "Set color adjustments"; @@ -494,9 +495,13 @@ void JsonConnection::setAdjustment( black.append(blackAdjustment.blue()); adjust["black"] = black; } - if (brightnessMin != nullptr) + if (backlightThreshold != nullptr) { - adjust["brightnessMin"] = *brightnessMin; + adjust["backlightThreshold"] = *backlightThreshold; + } + if (backlightColored != nullptr) + { + adjust["backlightColored"] = (*backlightColored == 0)? false : true; } if (brightness != nullptr) { diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index 3e0c7480..0cef3e44 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -134,7 +134,7 @@ public: /// @param greenAdjustment The green channel adjustment values /// @param blueAdjustment The blue channel adjustment values /// @param gamma The gamma value - /// @param brightnessMin The threshold aka backlight + /// @param backlightThreshold The threshold aka backlight /// @param brightness The threshold aka upper brightness limit void setAdjustment( @@ -150,7 +150,8 @@ public: double *gammaR, double *gammaG, double *gammaB, - double *brightnessMin, + double *backlightThreshold, + int *backlightColored, double *brightness); /// diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index 87de775d..1caaabbd 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -73,7 +73,8 @@ int main(int argc, char * argv[]) Option & argDisableComponent = parser.add