mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
fix/refactor backlight stuff (#394)
* fix/refactor backlight stuff: - fix colors dont turn of when backlight 0 and black is set - add option to use not colored backlight - fix colored backlight not colored on very low color values - various code style tunings * apply needed change to wizard * backlight disabled on static color and efects * fix warnings * try fix udp compiler warnings
This commit is contained in:
parent
199d266bc0
commit
e1165e112f
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"@metadata": {
|
"@metadata": {
|
||||||
"authors": [
|
"authors": [
|
||||||
"brindosch"
|
"brindosch"
|
||||||
],
|
],
|
||||||
"project" : "Hyperion WebUI",
|
"project" : "Hyperion WebUI",
|
||||||
"locale": "de",
|
"locale": "de",
|
||||||
"last-updated": "2016-11-30",
|
"last-updated": "2016-11-30",
|
||||||
"message-documentation": "qqq"
|
"message-documentation": "qqq"
|
||||||
},
|
},
|
||||||
"general_webui_title" : "Hyperion - Web Konfiguration",
|
"general_webui_title" : "Hyperion - Web Konfiguration",
|
||||||
"general_country_de" : "Deutschland",
|
"general_country_de" : "Deutschland",
|
||||||
"general_country_us" : "Amerika",
|
"general_country_us" : "Amerika",
|
||||||
@ -422,7 +422,8 @@
|
|||||||
"edt_conf_color_gammaGreen_expl" : "Gamma von grün.",
|
"edt_conf_color_gammaGreen_expl" : "Gamma von grün.",
|
||||||
"edt_conf_color_gammaBlue_title" : "Gamma blau",
|
"edt_conf_color_gammaBlue_title" : "Gamma blau",
|
||||||
"edt_conf_color_gammaBlue_expl" : "Gamma von 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_brightnessMin_expl" : "Auch als Hintergrundhelligkeit genutzt.",
|
||||||
"edt_conf_color_brightness_title" : "Maximale Helligkeit",
|
"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.",
|
"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.",
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"@metadata": {
|
"@metadata": {
|
||||||
"authors": [
|
"authors": [
|
||||||
"brindosch"
|
"brindosch"
|
||||||
],
|
],
|
||||||
"project" : "Hyperion WebUI",
|
"project" : "Hyperion WebUI",
|
||||||
"locale": "en",
|
"locale": "en",
|
||||||
"last-updated": "2016-11-30",
|
"last-updated": "2016-11-30",
|
||||||
"message-documentation": "qqq.json"
|
"message-documentation": "qqq.json"
|
||||||
},
|
},
|
||||||
"general_webui_title" : "Hyperion - Web Configuration",
|
"general_webui_title" : "Hyperion - Web Configuration",
|
||||||
"general_country_de" : "Germany",
|
"general_country_de" : "Germany",
|
||||||
"general_country_us" : "United States",
|
"general_country_us" : "United States",
|
||||||
@ -422,7 +422,8 @@
|
|||||||
"edt_conf_color_gammaGreen_expl" : "The gamma of green.",
|
"edt_conf_color_gammaGreen_expl" : "The gamma of green.",
|
||||||
"edt_conf_color_gammaBlue_title" : "gamma blue",
|
"edt_conf_color_gammaBlue_title" : "gamma blue",
|
||||||
"edt_conf_color_gammaBlue_expl" : "The gamma of 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_brightnessMin_expl" : "The minimum amount of brightness (backlight).",
|
||||||
"edt_conf_color_brightness_title" : "maximal brightness",
|
"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.",
|
"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.",
|
||||||
|
@ -347,7 +347,7 @@ $(document).ready( function() {
|
|||||||
}
|
}
|
||||||
if(step == 10)
|
if(step == 10)
|
||||||
{
|
{
|
||||||
updateWEditor(["brightnessMin"]);
|
updateWEditor(["backlightThreshold"]);
|
||||||
h = $.i18n('wiz_cc_minBright');
|
h = $.i18n('wiz_cc_minBright');
|
||||||
if(withKodi)
|
if(withKodi)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,8 @@
|
|||||||
/// * 'gammaRed'/'gammaGreen'/'gammaBlue' : Gamma value for each channel
|
/// * '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')
|
||||||
/// * '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).
|
/// * '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)
|
/// 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" :
|
"color" :
|
||||||
@ -71,7 +72,8 @@
|
|||||||
"gammaRed" : 1.0,
|
"gammaRed" : 1.0,
|
||||||
"gammaGreen" : 1.0,
|
"gammaGreen" : 1.0,
|
||||||
"gammaBlue" : 1.0,
|
"gammaBlue" : 1.0,
|
||||||
"brightnessMin" : 0.0,
|
"backlightThreshold" : 0.0,
|
||||||
|
"backlightColored" : false,
|
||||||
"brightness" : 0.5
|
"brightness" : 0.5
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
"gammaRed" : 1.0,
|
"gammaRed" : 1.0,
|
||||||
"gammaGreen" : 1.0,
|
"gammaGreen" : 1.0,
|
||||||
"gammaBlue" : 1.0,
|
"gammaBlue" : 1.0,
|
||||||
"brightnessMin" : 0.0,
|
"backlightThreshold" : 0.0,
|
||||||
|
"backlightColored" : false,
|
||||||
"brightness" : 0.75
|
"brightness" : 0.75
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef HYPERION_DOUBLECOMMANDLINEOPTION_H
|
#pragma once
|
||||||
#define HYPERION_DOUBLECOMMANDLINEOPTION_H
|
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include "ValidatorOption.h"
|
#include "ValidatorOption.h"
|
||||||
@ -9,32 +8,38 @@ namespace commandline
|
|||||||
|
|
||||||
class DoubleOption: public ValidatorOption
|
class DoubleOption: public ValidatorOption
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
double _double;
|
|
||||||
public:
|
public:
|
||||||
DoubleOption(const QString &name,
|
DoubleOption(const QString &name,
|
||||||
const QString &description = QString(),
|
const QString &description = QString(),
|
||||||
const QString &valueName = QString(),
|
const QString &valueName = QString(),
|
||||||
const QString &defaultValue = QString(),
|
const QString &defaultValue = QString(),
|
||||||
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
||||||
: ValidatorOption(name, description, valueName, defaultValue)
|
: ValidatorOption(name, description, valueName, defaultValue)
|
||||||
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
|
{
|
||||||
DoubleOption(const QStringList &names,
|
setValidator(new QDoubleValidator(minimum, maximum, decimals));
|
||||||
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);
|
DoubleOption(const QStringList &names,
|
||||||
double *getDoublePtr(Parser &parser, bool *ok = 0);
|
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
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef HYPERION_SWITCHCOMMANDLINEOPTION_H
|
#pragma once
|
||||||
#define HYPERION_SWITCHCOMMANDLINEOPTION_H
|
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
@ -10,10 +9,8 @@ namespace commandline
|
|||||||
template <class T>
|
template <class T>
|
||||||
class SwitchOption: public Option
|
class SwitchOption: public Option
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
QMap<QString, T> _switches;
|
|
||||||
public:
|
public:
|
||||||
SwitchOption(const QString &name,
|
SwitchOption(const QString &name,
|
||||||
const QString &description = QString(),
|
const QString &description = QString(),
|
||||||
const QString &valueName = QString(),
|
const QString &valueName = QString(),
|
||||||
const QString &defaultValue = QString(),
|
const QString &defaultValue = QString(),
|
||||||
@ -38,8 +35,9 @@ public:
|
|||||||
void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;}
|
void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;}
|
||||||
void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());}
|
void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());}
|
||||||
T & switchValue(Parser & parser){return _switches[value(parser).toLower()];}
|
T & switchValue(Parser & parser){return _switches[value(parser).toLower()];}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QMap<QString, T> _switches;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //HYPERION_SWITCHCOMMANDLINEOPTION_H
|
|
||||||
|
@ -368,4 +368,6 @@ private:
|
|||||||
int _ledMAppingType;
|
int _ledMAppingType;
|
||||||
|
|
||||||
int _configVersionId;
|
int _configVersionId;
|
||||||
|
|
||||||
|
hyperion::Components _prevCompId;
|
||||||
};
|
};
|
||||||
|
@ -20,10 +20,11 @@ public:
|
|||||||
/// @param gammaR The used red gamma
|
/// @param gammaR The used red gamma
|
||||||
/// @param gammaG The used green gamma
|
/// @param gammaG The used green gamma
|
||||||
/// @param gammab The used blue 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
|
/// @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
|
/// Destructor
|
||||||
@ -39,19 +40,34 @@ public:
|
|||||||
/// @return The current blue gamma value
|
/// @return The current blue gamma value
|
||||||
double getGammaB() const;
|
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);
|
void setGamma(double gammaR,double gammaG=-1, double gammaB=-1);
|
||||||
|
|
||||||
/// @return The current lower brightness
|
/// @return The current lower brightness
|
||||||
double getBrightnessMin() const;
|
double getBacklightThreshold() const;
|
||||||
|
|
||||||
/// @param gamma New lower brightness
|
/// @param backlightThreshold New lower brightness
|
||||||
void setBrightnessMin(double 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;
|
double getBrightness() const;
|
||||||
|
|
||||||
/// @param gamma New lower brightness
|
/// @param brightness New brightness
|
||||||
void setBrightness(double brightness);
|
void setBrightness(double brightness);
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -72,15 +88,17 @@ private:
|
|||||||
/// @param gammaR The used red gamma
|
/// @param gammaR The used red gamma
|
||||||
/// @param gammaG The used green gamma
|
/// @param gammaG The used green gamma
|
||||||
/// @param gammab The used blue 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
|
/// @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
|
/// (re)-initilize the color mapping
|
||||||
void initializeMapping(); /// The saturation gain
|
void initializeMapping(); /// The saturation gain
|
||||||
|
|
||||||
double _brightnessLow;
|
double _backlightThreshold;
|
||||||
|
bool _backlightColored;
|
||||||
double _brightnessHigh;
|
double _brightnessHigh;
|
||||||
double _sumBrightnessLow;
|
double _sumBrightnessLow;
|
||||||
double _sumBrightnessHigh;
|
double _sumBrightnessHigh;
|
||||||
@ -93,4 +111,6 @@ private:
|
|||||||
uint8_t _mappingR[256];
|
uint8_t _mappingR[256];
|
||||||
uint8_t _mappingG[256];
|
uint8_t _mappingG[256];
|
||||||
uint8_t _mappingB[256];
|
uint8_t _mappingB[256];
|
||||||
|
|
||||||
|
bool _backLightEnabled;
|
||||||
};
|
};
|
||||||
|
@ -6,25 +6,27 @@ using namespace commandline;
|
|||||||
|
|
||||||
bool ColorOption::validate(Parser & parser, QString & value)
|
bool ColorOption::validate(Parser & parser, QString & value)
|
||||||
{
|
{
|
||||||
// Check if we can create the color by name
|
// Check if we can create the color by name
|
||||||
_color = QColor(value);
|
_color = QColor(value);
|
||||||
if (_color.isValid()) {
|
if (_color.isValid())
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// check if we can create the color by hex RRGGBB getColors
|
// check if we can create the color by hex RRGGBB getColors
|
||||||
_color = QColor(QString("#%1").arg(value));
|
_color = QColor(QString("#%1").arg(value));
|
||||||
if (_color.isValid()) {
|
if (_color.isValid())
|
||||||
return true;
|
{
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!parser.isSet(*this)){
|
if(!parser.isSet(*this))
|
||||||
// Return true if no value is available
|
{
|
||||||
return true;
|
// 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;
|
||||||
}
|
}
|
||||||
|
@ -6,32 +6,36 @@ using namespace commandline;
|
|||||||
|
|
||||||
bool ColorsOption::validate(Parser & parser, QString & value)
|
bool ColorsOption::validate(Parser & parser, QString & value)
|
||||||
{
|
{
|
||||||
// Clear any old results
|
// Clear any old results
|
||||||
_colors.clear();
|
_colors.clear();
|
||||||
|
|
||||||
// Check if we can create the color by name
|
// Check if we can create the color by name
|
||||||
QColor color(value);
|
QColor color(value);
|
||||||
if (color.isValid()) {
|
if (color.isValid())
|
||||||
_colors.push_back(color);
|
{
|
||||||
return true;
|
_colors.push_back(color);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// check if we can create the color by hex RRGGBB getColors
|
// check if we can create the color by hex RRGGBB getColors
|
||||||
QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption);
|
||||||
QRegularExpressionMatch match = hexRe.match(value);
|
QRegularExpressionMatch match = hexRe.match(value);
|
||||||
if(match.hasMatch()) {
|
if(match.hasMatch())
|
||||||
Q_FOREACH(const QString m, match.capturedTexts()){
|
{
|
||||||
_colors.push_back(QColor(QString("#%1").arg(m)));
|
Q_FOREACH(const QString m, match.capturedTexts())
|
||||||
}
|
{
|
||||||
return true;
|
_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 if no value is available
|
||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,17 @@ using namespace commandline;
|
|||||||
|
|
||||||
double DoubleOption::getDouble(Parser &parser, bool *ok)
|
double DoubleOption::getDouble(Parser &parser, bool *ok)
|
||||||
{
|
{
|
||||||
_double = value(parser).toDouble(ok);
|
_double = value(parser).toDouble(ok);
|
||||||
return _double;
|
return _double;
|
||||||
}
|
}
|
||||||
|
|
||||||
double *DoubleOption::getDoublePtr(Parser &parser, bool *ok)
|
double *DoubleOption::getDoublePtr(Parser &parser, bool *ok)
|
||||||
{
|
{
|
||||||
if (parser.isSet(this)) {
|
if (parser.isSet(this))
|
||||||
getDouble(parser, ok);
|
{
|
||||||
return &_double;
|
getDouble(parser, ok);
|
||||||
} else {
|
return &_double;
|
||||||
return nullptr;
|
}
|
||||||
}
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ using namespace commandline;
|
|||||||
|
|
||||||
bool ImageOption::validate(Parser & parser, QString & value)
|
bool ImageOption::validate(Parser & parser, QString & value)
|
||||||
{
|
{
|
||||||
if(value.size()){
|
if(value.size())
|
||||||
|
{
|
||||||
_image = QImage(value);
|
_image = QImage(value);
|
||||||
|
|
||||||
if (_image.isNull())
|
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);
|
_error = QString("File %1 could not be opened as image").arg(value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ using namespace commandline;
|
|||||||
|
|
||||||
int IntOption::getInt(Parser &parser, bool *ok, int base)
|
int IntOption::getInt(Parser &parser, bool *ok, int base)
|
||||||
{
|
{
|
||||||
_int = value(parser).toInt(ok, base);
|
_int = value(parser).toInt(ok, base);
|
||||||
return _int;
|
return _int;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *IntOption::getIntPtr(Parser &parser, bool *ok, int base)
|
int *IntOption::getIntPtr(Parser &parser, bool *ok, int base)
|
||||||
{
|
{
|
||||||
if (parser.isSet(this)) {
|
if (parser.isSet(this))
|
||||||
getInt(parser, ok, base);
|
{
|
||||||
return &_int;
|
getInt(parser, ok, base);
|
||||||
} else {
|
return &_int;
|
||||||
return nullptr;
|
}
|
||||||
}
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -6,26 +6,26 @@ using namespace commandline;
|
|||||||
bool Option::validate(Parser & parser, QString &value)
|
bool Option::validate(Parser & parser, QString &value)
|
||||||
{
|
{
|
||||||
/* By default everything is accepted */
|
/* By default everything is accepted */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Option::value(Parser &parser)
|
QString Option::value(Parser &parser)
|
||||||
{
|
{
|
||||||
return parser.value(*this);
|
return parser.value(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Option::getStdString(Parser &parser)
|
std::string Option::getStdString(Parser &parser)
|
||||||
{
|
{
|
||||||
return value(parser).toStdString();
|
return value(parser).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring Option::getStdWString(Parser &parser)
|
std::wstring Option::getStdWString(Parser &parser)
|
||||||
{
|
{
|
||||||
return value(parser).toStdWString();
|
return value(parser).toStdWString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Option::getCString(Parser &parser)
|
const char* Option::getCString(Parser &parser)
|
||||||
{
|
{
|
||||||
return value(parser).toLocal8Bit().constData();
|
return value(parser).toLocal8Bit().constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,85 +6,88 @@ using namespace commandline;
|
|||||||
|
|
||||||
bool Parser::parse(const QStringList &arguments)
|
bool Parser::parse(const QStringList &arguments)
|
||||||
{
|
{
|
||||||
if (!_parser.parse(arguments)) {
|
if (!_parser.parse(arguments))
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Q_FOREACH(Option * option, _options) {
|
Q_FOREACH(Option * option, _options)
|
||||||
QString value = this->value(*option);
|
{
|
||||||
if (!option->validate(*this, value)) {
|
QString value = this->value(*option);
|
||||||
const QString error = option->getError();
|
if (!option->validate(*this, value)) {
|
||||||
if (error.size()) {
|
const QString error = option->getError();
|
||||||
_errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error);
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
return true;
|
{
|
||||||
|
_errorText = tr("%1 is not a valid option for %2").arg(value, option->name());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::process(const QStringList &arguments)
|
void Parser::process(const QStringList &arguments)
|
||||||
{
|
{
|
||||||
_parser.process(arguments);
|
_parser.process(arguments);
|
||||||
if (!parse(arguments)) {
|
if (!parse(arguments))
|
||||||
|
{
|
||||||
fprintf(stdout, "%s", qPrintable(tr("Error: %1").arg(_errorText)));
|
fprintf(stdout, "%s", qPrintable(tr("Error: %1").arg(_errorText)));
|
||||||
showHelp(EXIT_FAILURE);
|
showHelp(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::process(const QCoreApplication &app)
|
void Parser::process(const QCoreApplication &app)
|
||||||
{
|
{
|
||||||
Q_UNUSED(app);
|
Q_UNUSED(app);
|
||||||
process(QCoreApplication::arguments());
|
process(QCoreApplication::arguments());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Parser::errorText() const
|
QString Parser::errorText() const
|
||||||
{
|
{
|
||||||
if (_errorText.size()) {
|
return (_errorText.size()) ? _errorText : _parser.errorText();
|
||||||
return _errorText;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return _parser.errorText();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::addOption(Option &option)
|
bool Parser::addOption(Option &option)
|
||||||
{
|
{
|
||||||
return addOption(&option);
|
return addOption(&option);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::addOption(Option * const option)
|
bool Parser::addOption(Option * const option)
|
||||||
{
|
{
|
||||||
_options[option->name()] = option;
|
_options[option->name()] = option;
|
||||||
return _parser.addOption(*option);
|
return _parser.addOption(*option);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Parser::_getNames(const char shortOption, const QString longOption)
|
QStringList Parser::_getNames(const char shortOption, const QString longOption)
|
||||||
{
|
{
|
||||||
QStringList names;
|
QStringList names;
|
||||||
if (shortOption != 0x0) {
|
if (shortOption != 0x0)
|
||||||
|
{
|
||||||
names << QString(shortOption);
|
names << QString(shortOption);
|
||||||
}
|
}
|
||||||
if (longOption.size()) {
|
if (longOption.size())
|
||||||
|
{
|
||||||
names << longOption;
|
names << longOption;
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Parser::_getDescription(const QString description, const QString default_)
|
QString Parser::_getDescription(const QString description, const QString default_)
|
||||||
{
|
{
|
||||||
/* Add the translations if available */
|
/* Add the translations if available */
|
||||||
QString formattedDescription(tr(qPrintable(description)));
|
QString formattedDescription(tr(qPrintable(description)));
|
||||||
|
|
||||||
/* Fill in the default if needed */
|
/* Fill in the default if needed */
|
||||||
if (default_.size()) {
|
if (default_.size())
|
||||||
if(!formattedDescription.contains("%1")){
|
{
|
||||||
|
if(!formattedDescription.contains("%1"))
|
||||||
|
{
|
||||||
formattedDescription += " [default: %1]";
|
formattedDescription += " [default: %1]";
|
||||||
}
|
}
|
||||||
formattedDescription = formattedDescription.arg(default_);
|
formattedDescription = formattedDescription.arg(default_);
|
||||||
}
|
}
|
||||||
return formattedDescription;
|
return formattedDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,21 +5,22 @@ using namespace commandline;
|
|||||||
|
|
||||||
bool ValidatorOption::validate(Parser & parser, QString & value)
|
bool ValidatorOption::validate(Parser & parser, QString & value)
|
||||||
{
|
{
|
||||||
if (parser.isSet(*this) || !defaultValues().empty()) {
|
if (parser.isSet(*this) || !defaultValues().empty())
|
||||||
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
validator->fixup(value);
|
validator->fixup(value);
|
||||||
return validator->validate(value, pos) == QValidator::Acceptable;
|
return validator->validate(value, pos) == QValidator::Acceptable;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QValidator *ValidatorOption::getValidator() const
|
const QValidator *ValidatorOption::getValidator() const
|
||||||
{
|
{
|
||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
void ValidatorOption::setValidator(const QValidator *validator)
|
|
||||||
{
|
void ValidatorOption::setValidator(const QValidator *validator)
|
||||||
ValidatorOption::validator = validator;
|
{
|
||||||
|
ValidatorOption::validator = validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,13 +158,14 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
|
|||||||
|
|
||||||
RgbTransform* Hyperion::createRgbTransform(const QJsonObject& colorConfig)
|
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 brightness = colorConfig["brightness"].toDouble(0.5);
|
||||||
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
|
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
|
||||||
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
|
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
|
||||||
const double gammaB = colorConfig["gammaBlue"].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;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,10 +393,10 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
|
|||||||
, _timer()
|
, _timer()
|
||||||
, _log(CORE_LOGGER)
|
, _log(CORE_LOGGER)
|
||||||
, _hwLedCount(_ledString.leds().size())
|
, _hwLedCount(_ledString.leds().size())
|
||||||
|
|
||||||
, _sourceAutoSelectEnabled(true)
|
, _sourceAutoSelectEnabled(true)
|
||||||
, _configHash()
|
, _configHash()
|
||||||
, _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"]))
|
, _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"]))
|
||||||
|
, _prevCompId(hyperion::COMP_INVALID)
|
||||||
{
|
{
|
||||||
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
|
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
|
||||||
|
|
||||||
@ -718,6 +719,12 @@ void Hyperion::update()
|
|||||||
|
|
||||||
if ( priority < PriorityMuxer::LOWEST_PRIORITY)
|
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);
|
_raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ bool MultiColorAdjustment::verifyAdjustments() const
|
|||||||
Error(_log, "No adjustment set for %d", iLed);
|
Error(_log, "No adjustment set for %d", iLed);
|
||||||
return false;
|
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);
|
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;
|
return true;
|
||||||
@ -81,6 +81,15 @@ ColorAdjustment* MultiColorAdjustment::getAdjustment(const std::string& id)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiColorAdjustment::setBacklightEnabled(bool enable)
|
||||||
|
{
|
||||||
|
for (ColorAdjustment* adjustment : _adjustment)
|
||||||
|
{
|
||||||
|
adjustment->_rgbTransform.setBackLightEnabled(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
||||||
{
|
{
|
||||||
const size_t itCnt = std::min(_ledAdjustments.size(), ledColors.size());
|
const size_t itCnt = std::min(_ledAdjustments.size(), ledColors.size());
|
||||||
|
@ -30,6 +30,8 @@ public:
|
|||||||
|
|
||||||
bool verifyAdjustments() const;
|
bool verifyAdjustments() const;
|
||||||
|
|
||||||
|
void setBacklightEnabled(bool enable);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the identifier of all the unique ColorAdjustment
|
/// Returns the identifier of all the unique ColorAdjustment
|
||||||
///
|
///
|
||||||
|
@ -271,10 +271,10 @@
|
|||||||
"maxItems" : 3,
|
"maxItems" : 3,
|
||||||
"propertyOrder" : 10
|
"propertyOrder" : 10
|
||||||
},
|
},
|
||||||
"brightnessMin" :
|
"backlightThreshold" :
|
||||||
{
|
{
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
"title" : "edt_conf_color_brightnessMin_title",
|
"title" : "edt_conf_color_backlightThreshold_title",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"minimum" : 0.0,
|
"minimum" : 0.0,
|
||||||
"maximum": 1.0,
|
"maximum": 1.0,
|
||||||
@ -282,6 +282,14 @@
|
|||||||
"step" : 0.05,
|
"step" : 0.05,
|
||||||
"propertyOrder" : 11
|
"propertyOrder" : 11
|
||||||
},
|
},
|
||||||
|
"backlightColored" :
|
||||||
|
{
|
||||||
|
"type" : "boolean",
|
||||||
|
"title" : "edt_conf_color_backlightColored_title",
|
||||||
|
"required" : true,
|
||||||
|
"default" : false,
|
||||||
|
"propertyOrder" : 12
|
||||||
|
},
|
||||||
"brightness" :
|
"brightness" :
|
||||||
{
|
{
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
@ -291,7 +299,7 @@
|
|||||||
"maximum": 1.0,
|
"maximum": 1.0,
|
||||||
"default" : 1.0,
|
"default" : 1.0,
|
||||||
"step" : 0.05,
|
"step" : 0.05,
|
||||||
"propertyOrder" : 12
|
"propertyOrder" : 13
|
||||||
},
|
},
|
||||||
"gammaRed" :
|
"gammaRed" :
|
||||||
{
|
{
|
||||||
@ -302,7 +310,7 @@
|
|||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"default" : 1.0,
|
"default" : 1.0,
|
||||||
"step" : 0.1,
|
"step" : 0.1,
|
||||||
"propertyOrder" : 13
|
"propertyOrder" : 14
|
||||||
},
|
},
|
||||||
"gammaGreen" :
|
"gammaGreen" :
|
||||||
{
|
{
|
||||||
@ -313,7 +321,7 @@
|
|||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"default" : 1.0,
|
"default" : 1.0,
|
||||||
"step" : 0.1,
|
"step" : 0.1,
|
||||||
"propertyOrder" : 14
|
"propertyOrder" : 15
|
||||||
},
|
},
|
||||||
"gammaBlue" :
|
"gammaBlue" :
|
||||||
{
|
{
|
||||||
@ -324,7 +332,7 @@
|
|||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"default" : 1.0,
|
"default" : 1.0,
|
||||||
"step" : 0.1,
|
"step" : 0.1,
|
||||||
"propertyOrder" : 15
|
"propertyOrder" : 16
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties" : false
|
"additionalProperties" : false
|
||||||
|
@ -731,11 +731,12 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
|
|||||||
yellowAdjust.append(colorAdjustment->_rgbYellowAdjustment.getAdjustmentB());
|
yellowAdjust.append(colorAdjustment->_rgbYellowAdjustment.getAdjustmentB());
|
||||||
adjustment.insert("yellow", yellowAdjust);
|
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["brightness"] = colorAdjustment->_rgbTransform.getBrightness();
|
||||||
adjustment["gammaRed"] = colorAdjustment->_rgbTransform.getGammaR();
|
adjustment["gammaRed"] = colorAdjustment->_rgbTransform.getGammaR();
|
||||||
adjustment["gammaGreen"] = colorAdjustment->_rgbTransform.getGammaG();
|
adjustment["gammaGreen"] = colorAdjustment->_rgbTransform.getGammaG();
|
||||||
adjustment["gammaBlue"] = colorAdjustment->_rgbTransform.getGammaB();
|
adjustment["gammaBlue"] = colorAdjustment->_rgbTransform.getGammaB();
|
||||||
|
|
||||||
adjustmentArray.append(adjustment);
|
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());
|
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"))
|
if (adjustment.contains("brightness"))
|
||||||
{
|
{
|
||||||
|
@ -351,13 +351,13 @@ private:
|
|||||||
|
|
||||||
// masks for fields in the basic header
|
// masks for fields in the basic header
|
||||||
static uint8_t const BHB0_OPCODE = 0x0F;
|
static uint8_t const BHB0_OPCODE = 0x0F;
|
||||||
static uint8_t const BHB0_RSV3 = 0x10;
|
static uint8_t const BHB0_RSV3 = 0x10;
|
||||||
static uint8_t const BHB0_RSV2 = 0x20;
|
static uint8_t const BHB0_RSV2 = 0x20;
|
||||||
static uint8_t const BHB0_RSV1 = 0x40;
|
static uint8_t const BHB0_RSV1 = 0x40;
|
||||||
static uint8_t const BHB0_FIN = 0x80;
|
static uint8_t const BHB0_FIN = 0x80;
|
||||||
|
|
||||||
static uint8_t const BHB1_PAYLOAD = 0x7F;
|
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_16bit = 0x7E; // 126
|
||||||
static uint8_t const payload_size_code_64bit = 0x7F; // 127
|
static uint8_t const payload_size_code_64bit = 0x7F; // 127
|
||||||
|
@ -124,12 +124,16 @@
|
|||||||
"minimum" : 0.0,
|
"minimum" : 0.0,
|
||||||
"maximum" : 100.0
|
"maximum" : 100.0
|
||||||
},
|
},
|
||||||
"brightnessMin" : {
|
"backlightThreshold" : {
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
"required" : false,
|
"required" : false,
|
||||||
"minimum" : 0.0,
|
"minimum" : 0.0,
|
||||||
"maximum" : 1.0
|
"maximum" : 1.0
|
||||||
},
|
},
|
||||||
|
"backlightColored" : {
|
||||||
|
"type" : "boolean",
|
||||||
|
"required" : false
|
||||||
|
},
|
||||||
"brightness" : {
|
"brightness" : {
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
"required" : false,
|
"required" : false,
|
||||||
|
@ -82,17 +82,17 @@ typedef union
|
|||||||
} e131_packet_t;
|
} e131_packet_t;
|
||||||
|
|
||||||
/* defined parameters from http://tsp.esta.org/tsp/documents/docs/BSR_E1-31-20xx_CP-2014-1009r2.pdf */
|
/* 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_DATA 0x00000004
|
||||||
#define VECTOR_ROOT_E131_EXTENDED 0x00000008
|
#define VECTOR_ROOT_E131_EXTENDED 0x00000008
|
||||||
#define VECTOR_DMP_SET_PROPERTY 0x02
|
#define VECTOR_DMP_SET_PROPERTY 0x02
|
||||||
#define VECTOR_E131_DATA_PACKET 0x00000002
|
#define VECTOR_E131_DATA_PACKET 0x00000002
|
||||||
#define VECTOR_E131_EXTENDED_SYNCHRONIZATION 0x00000001
|
#define VECTOR_E131_EXTENDED_SYNCHRONIZATION 0x00000001
|
||||||
#define VECTOR_E131_EXTENDED_DISCOVERY 0x00000002
|
#define VECTOR_E131_EXTENDED_DISCOVERY 0x00000002
|
||||||
#define VECTOR_UNIVERSE_DISCOVERY_UNIVERSE_LIST 0x00000001
|
#define VECTOR_UNIVERSE_DISCOVERY_UNIVERSE_LIST 0x00000001
|
||||||
#define E131_E131_UNIVERSE_DISCOVERY_INTERVAL 10 // seconds
|
#define E131_E131_UNIVERSE_DISCOVERY_INTERVAL 10 // seconds
|
||||||
#define E131_NETWORK_DATA_LOSS_TIMEOUT 2500 // milli econds
|
#define E131_NETWORK_DATA_LOSS_TIMEOUT 2500 // milli econds
|
||||||
#define E131_DISCOVERY_UNIVERSE 64214
|
#define E131_DISCOVERY_UNIVERSE 64214
|
||||||
#define DMX_MAX 512 // 512 usable slots
|
#define DMX_MAX 512 // 512 usable slots
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets
|
/// Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets
|
||||||
|
@ -11,7 +11,8 @@ bool LedDeviceUdpH801::init(const QJsonObject &deviceConfig)
|
|||||||
/* The H801 port is fixed */
|
/* The H801 port is fixed */
|
||||||
_LatchTime_ns = 10000000;
|
_LatchTime_ns = 10000000;
|
||||||
_port = 30977;
|
_port = 30977;
|
||||||
ProviderUdp::init(deviceConfig, "255.255.255.255");
|
_defaultHost = "255.255.255.255";
|
||||||
|
ProviderUdp::init(deviceConfig);
|
||||||
|
|
||||||
_ids.clear();
|
_ids.clear();
|
||||||
QJsonArray lArray = deviceConfig["lightIds"].toArray();
|
QJsonArray lArray = deviceConfig["lightIds"].toArray();
|
||||||
|
@ -19,6 +19,7 @@ ProviderUdp::ProviderUdp()
|
|||||||
: LedDevice()
|
: LedDevice()
|
||||||
, _LatchTime_ns(-1)
|
, _LatchTime_ns(-1)
|
||||||
, _port(1)
|
, _port(1)
|
||||||
|
, _defaultHost("127.0.0.1")
|
||||||
{
|
{
|
||||||
_udpSocket = new QUdpSocket();
|
_udpSocket = new QUdpSocket();
|
||||||
}
|
}
|
||||||
@ -28,11 +29,11 @@ ProviderUdp::~ProviderUdp()
|
|||||||
_udpSocket->close();
|
_udpSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProviderUdp::init(const QJsonObject &deviceConfig, std::string defaultHost)
|
bool ProviderUdp::init(const QJsonObject &deviceConfig)
|
||||||
{
|
{
|
||||||
LedDevice::init(deviceConfig);
|
LedDevice::init(deviceConfig);
|
||||||
|
|
||||||
QString host = deviceConfig["host"].toString(QString::fromStdString(defaultHost));
|
QString host = deviceConfig["host"].toString(_defaultHost);
|
||||||
|
|
||||||
if (_address.setAddress(host) )
|
if (_address.setAddress(host) )
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param deviceConfig the json device config
|
/// @param deviceConfig the json device config
|
||||||
/// @return true if success
|
/// @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
|
/// Opens and configures the output device
|
||||||
@ -55,4 +55,5 @@ protected:
|
|||||||
QUdpSocket * _udpSocket;
|
QUdpSocket * _udpSocket;
|
||||||
QHostAddress _address;
|
QHostAddress _address;
|
||||||
quint16 _port;
|
quint16 _port;
|
||||||
|
QString _defaultHost;
|
||||||
};
|
};
|
||||||
|
@ -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 const int LogLevelSysLog[] = { LOG_DEBUG, LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERR };
|
||||||
static unsigned int loggerCount = 0;
|
static unsigned int loggerCount = 0;
|
||||||
static unsigned int loggerId = 0;
|
static unsigned int loggerId = 0;
|
||||||
static const int loggerMaxMsgBufferSize = 50;
|
|
||||||
|
|
||||||
std::map<std::string,Logger*> *Logger::LoggerMap = nullptr;
|
std::map<std::string,Logger*> *Logger::LoggerMap = nullptr;
|
||||||
Logger::LogLevel Logger::GLOBAL_MIN_LOG_LEVEL = Logger::UNSET;
|
Logger::LogLevel Logger::GLOBAL_MIN_LOG_LEVEL = Logger::UNSET;
|
||||||
|
@ -5,18 +5,20 @@
|
|||||||
|
|
||||||
RgbTransform::RgbTransform()
|
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);
|
setGamma(gammaR,gammaG,gammaB);
|
||||||
setBrightnessMin(brightnessLow);
|
setBacklightThreshold(backlightThreshold);
|
||||||
|
setBacklightColored(backlightColored);
|
||||||
setBrightness(brightnessHigh);
|
setBrightness(brightnessHigh);
|
||||||
initializeMapping();
|
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;
|
_backlightThreshold = backlightThreshold;
|
||||||
_sumBrightnessLow = 765.0 * ((std::pow(2.0,brightness*2)-1) / 3.0);
|
_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
|
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 << " => ";
|
//std::cout << (int)red << " " << (int)green << " " << (int)blue << " => ";
|
||||||
// apply brightnesss
|
// apply brightnesss
|
||||||
if (red ==0) red = 1;
|
|
||||||
if (green==0) green = 1;
|
|
||||||
if (blue ==0) blue = 1;
|
|
||||||
|
|
||||||
int rgbSum = red+green+blue;
|
int rgbSum = red+green+blue;
|
||||||
|
|
||||||
if (rgbSum > _sumBrightnessHigh)
|
if (_sumBrightnessHigh > 0 && rgbSum > _sumBrightnessHigh)
|
||||||
{
|
{
|
||||||
double cH = _sumBrightnessHigh / rgbSum;
|
double cH = _sumBrightnessHigh / rgbSum;
|
||||||
red *= cH;
|
red *= cH;
|
||||||
green *= cH;
|
green *= cH;
|
||||||
blue *= cH;
|
blue *= cH;
|
||||||
}
|
}
|
||||||
else if (rgbSum < _sumBrightnessLow)
|
else if ( _backLightEnabled && _sumBrightnessLow>0 && rgbSum < _sumBrightnessLow)
|
||||||
{
|
{
|
||||||
double cL = _sumBrightnessLow / rgbSum;
|
if (_backlightColored)
|
||||||
red *= cL;
|
{
|
||||||
green *= cL;
|
if (rgbSum == 0)
|
||||||
blue *= cL;
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,8 @@ void JsonConnection::setAdjustment(
|
|||||||
double *gammaR,
|
double *gammaR,
|
||||||
double *gammaG,
|
double *gammaG,
|
||||||
double *gammaB,
|
double *gammaB,
|
||||||
double *brightnessMin,
|
double *backlightThreshold,
|
||||||
|
int *backlightColored,
|
||||||
double *brightness)
|
double *brightness)
|
||||||
{
|
{
|
||||||
qDebug() << "Set color adjustments";
|
qDebug() << "Set color adjustments";
|
||||||
@ -494,9 +495,13 @@ void JsonConnection::setAdjustment(
|
|||||||
black.append(blackAdjustment.blue());
|
black.append(blackAdjustment.blue());
|
||||||
adjust["black"] = black;
|
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)
|
if (brightness != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -134,7 +134,7 @@ public:
|
|||||||
/// @param greenAdjustment The green channel adjustment values
|
/// @param greenAdjustment The green channel adjustment values
|
||||||
/// @param blueAdjustment The blue channel adjustment values
|
/// @param blueAdjustment The blue channel adjustment values
|
||||||
/// @param gamma The gamma value
|
/// @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
|
/// @param brightness The threshold aka upper brightness limit
|
||||||
|
|
||||||
void setAdjustment(
|
void setAdjustment(
|
||||||
@ -150,7 +150,8 @@ public:
|
|||||||
double *gammaR,
|
double *gammaR,
|
||||||
double *gammaG,
|
double *gammaG,
|
||||||
double *gammaB,
|
double *gammaB,
|
||||||
double *brightnessMin,
|
double *backlightThreshold,
|
||||||
|
int *backlightColored,
|
||||||
double *brightness);
|
double *brightness);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -73,7 +73,8 @@ int main(int argc, char * argv[])
|
|||||||
Option & argDisableComponent = parser.add<Option> ('D', "disable" , "Disable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER, V4L]");
|
Option & argDisableComponent = parser.add<Option> ('D', "disable" , "Disable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER, V4L]");
|
||||||
Option & argId = parser.add<Option> ('q', "qualifier" , "Identifier(qualifier) of the adjustment to set");
|
Option & argId = parser.add<Option> ('q', "qualifier" , "Identifier(qualifier) of the adjustment to set");
|
||||||
DoubleOption & argBrightness = parser.add<DoubleOption> ('L', "brightness" , "Set the brightness gain of the leds");
|
DoubleOption & argBrightness = parser.add<DoubleOption> ('L', "brightness" , "Set the brightness gain of the leds");
|
||||||
DoubleOption & argBrightnessMin= parser.add<DoubleOption> ('n', "brightnessMin" , "Set the brightness minimum of the leds (backlight)");
|
DoubleOption & argBacklightThreshold= parser.add<DoubleOption> ('n', "backlightThreshold" , "threshold for activating backlight (minimum brightness)");
|
||||||
|
IntOption & argBacklightColored = parser.add<IntOption> (0x0, "backlightColored" , "0 = white backlight; 1 = colored backlight");
|
||||||
DoubleOption & argGamma = parser.add<DoubleOption> ('g', "gamma" , "Set the overall gamma of the leds");
|
DoubleOption & argGamma = parser.add<DoubleOption> ('g', "gamma" , "Set the overall gamma of the leds");
|
||||||
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print" , "Print the json input and output messages on stdout");
|
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print" , "Print the json input and output messages on stdout");
|
||||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help" , "Show this help message and exit");
|
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help" , "Show this help message and exit");
|
||||||
@ -104,7 +105,8 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
// check if at least one of the available color transforms is set
|
// check if at least one of the available color transforms is set
|
||||||
bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust) || parser.isSet(argCAdjust) || parser.isSet(argMAdjust)
|
bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust) || parser.isSet(argCAdjust) || parser.isSet(argMAdjust)
|
||||||
|| parser.isSet(argYAdjust) || parser.isSet(argWAdjust) || parser.isSet(argbAdjust) || parser.isSet(argGamma)|| parser.isSet(argBrightness)|| parser.isSet(argBrightnessMin);
|
|| parser.isSet(argYAdjust) || parser.isSet(argWAdjust) || parser.isSet(argbAdjust) || parser.isSet(argGamma)|| parser.isSet(argBrightness)
|
||||||
|
|| parser.isSet(argBacklightThreshold) || parser.isSet(argBacklightColored);
|
||||||
|
|
||||||
// check that exactly one command was given
|
// check that exactly one command was given
|
||||||
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
|
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
|
||||||
@ -130,7 +132,8 @@ int main(int argc, char * argv[])
|
|||||||
qWarning() << "or one or more of the available color modding operations:";
|
qWarning() << "or one or more of the available color modding operations:";
|
||||||
showHelp(argId);
|
showHelp(argId);
|
||||||
showHelp(argBrightness);
|
showHelp(argBrightness);
|
||||||
showHelp(argBrightnessMin);
|
showHelp(argBacklightThreshold);
|
||||||
|
showHelp(argBacklightColored);
|
||||||
showHelp(argGamma);
|
showHelp(argGamma);
|
||||||
showHelp(argRAdjust);
|
showHelp(argRAdjust);
|
||||||
showHelp(argGAdjust);
|
showHelp(argGAdjust);
|
||||||
@ -232,7 +235,8 @@ int main(int argc, char * argv[])
|
|||||||
argGamma.getDoublePtr(parser),
|
argGamma.getDoublePtr(parser),
|
||||||
argGamma.getDoublePtr(parser),
|
argGamma.getDoublePtr(parser),
|
||||||
argGamma.getDoublePtr(parser),
|
argGamma.getDoublePtr(parser),
|
||||||
argBrightnessMin.getDoublePtr(parser),
|
argBacklightThreshold.getDoublePtr(parser),
|
||||||
|
argBacklightColored.getIntPtr(parser),
|
||||||
argBrightness.getDoublePtr(parser)
|
argBrightness.getDoublePtr(parser)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user