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
@ -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.",
|
||||||
|
@ -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,8 +8,6 @@ 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(),
|
||||||
@ -18,23 +15,31 @@ public:
|
|||||||
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)); }
|
{
|
||||||
|
setValidator(new QDoubleValidator(minimum, maximum, decimals));
|
||||||
|
}
|
||||||
|
|
||||||
DoubleOption(const QStringList &names,
|
DoubleOption(const QStringList &names,
|
||||||
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(names, description, valueName, defaultValue)
|
: ValidatorOption(names, description, valueName, defaultValue)
|
||||||
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
|
{
|
||||||
DoubleOption(const QCommandLineOption &other,
|
setValidator(new QDoubleValidator(minimum, maximum, decimals));
|
||||||
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
}
|
||||||
|
|
||||||
|
DoubleOption(const QCommandLineOption &other, double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
||||||
: ValidatorOption(other)
|
: ValidatorOption(other)
|
||||||
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
|
{
|
||||||
|
setValidator(new QDoubleValidator(minimum, maximum, decimals));
|
||||||
|
}
|
||||||
|
|
||||||
double getDouble(Parser &parser, bool *ok = 0);
|
double getDouble(Parser &parser, bool *ok = 0);
|
||||||
double *getDoublePtr(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,8 +9,6 @@ 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(),
|
||||||
@ -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;
|
||||||
};
|
};
|
||||||
|
@ -8,22 +8,24 @@ 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 if no value is available
|
||||||
return true;
|
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;
|
||||||
|
@ -11,7 +11,8 @@ bool ColorsOption::validate(Parser & parser, QString & value)
|
|||||||
|
|
||||||
// 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);
|
_colors.push_back(color);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -19,14 +20,17 @@ bool ColorsOption::validate(Parser & parser, QString & value)
|
|||||||
// 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()){
|
{
|
||||||
|
Q_FOREACH(const QString m, match.capturedTexts())
|
||||||
|
{
|
||||||
_colors.push_back(QColor(QString("#%1").arg(m)));
|
_colors.push_back(QColor(QString("#%1").arg(m)));
|
||||||
}
|
}
|
||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,11 @@ double DoubleOption::getDouble(Parser &parser, bool *ok)
|
|||||||
|
|
||||||
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);
|
getDouble(parser, ok);
|
||||||
return &_double;
|
return &_double;
|
||||||
} else {
|
|
||||||
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())
|
||||||
|
@ -11,10 +11,10 @@ int IntOption::getInt(Parser &parser, bool *ok, int base)
|
|||||||
|
|
||||||
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);
|
getInt(parser, ok, base);
|
||||||
return &_int;
|
return &_int;
|
||||||
} else {
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,21 @@ 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);
|
QString value = this->value(*option);
|
||||||
if (!option->validate(*this, value)) {
|
if (!option->validate(*this, value)) {
|
||||||
const QString error = option->getError();
|
const QString error = option->getError();
|
||||||
if (error.size()) {
|
if (error.size()) {
|
||||||
_errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error);
|
_errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
_errorText = tr("%1 is not a valid option for %2").arg(value, option->name());
|
_errorText = tr("%1 is not a valid option for %2").arg(value, option->name());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -29,8 +32,8 @@ bool Parser::parse(const QStringList &arguments)
|
|||||||
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);
|
||||||
}
|
}
|
||||||
@ -44,12 +47,7 @@ void Parser::process(const QCoreApplication &app)
|
|||||||
|
|
||||||
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)
|
||||||
@ -62,29 +60,34 @@ 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,19 +5,20 @@ 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,7 +731,8 @@ 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();
|
||||||
@ -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"))
|
||||||
{
|
{
|
||||||
|
@ -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,
|
||||||
|
@ -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)
|
||||||
|
{
|
||||||
|
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;
|
red *= cL;
|
||||||
green *= cL;
|
green *= cL;
|
||||||
blue *= cL;
|
blue *= cL;
|
||||||
}
|
}
|
||||||
//std::cout << (int)red << " " << (int)green << " " << (int)blue << std::endl;
|
else
|
||||||
|
{
|
||||||
|
red = std::min((int)(_sumBrightnessLow/3.0), 255);
|
||||||
|
green = red;
|
||||||
|
blue = red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//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