Skip to content

Commit e1165e1

Browse files
authored
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
1 parent 199d266 commit e1165e1

33 files changed

+362
-238
lines changed

assets/webconfig/i18n/de.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"@metadata": {
3-
"authors": [
4-
"brindosch"
5-
],
6-
"project" : "Hyperion WebUI",
7-
"locale": "de",
2+
"@metadata": {
3+
"authors": [
4+
"brindosch"
5+
],
6+
"project" : "Hyperion WebUI",
7+
"locale": "de",
88
"last-updated": "2016-11-30",
9-
"message-documentation": "qqq"
10-
},
9+
"message-documentation": "qqq"
10+
},
1111
"general_webui_title" : "Hyperion - Web Konfiguration",
1212
"general_country_de" : "Deutschland",
1313
"general_country_us" : "Amerika",
@@ -422,7 +422,8 @@
422422
"edt_conf_color_gammaGreen_expl" : "Gamma von grün.",
423423
"edt_conf_color_gammaBlue_title" : "Gamma blau",
424424
"edt_conf_color_gammaBlue_expl" : "Gamma von blau",
425-
"edt_conf_color_brightnessMin_title" : "Minimale Helligkeit",
425+
"edt_conf_color_backlightThreshold_title" : "Minimale Helligkeit",
426+
"edt_conf_color_backlightColored_title" : "Farbige Hintergrundbeleuchtung",
426427
"edt_conf_color_brightnessMin_expl" : "Auch als Hintergrundhelligkeit genutzt.",
427428
"edt_conf_color_brightness_title" : "Maximale Helligkeit",
428429
"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.",

assets/webconfig/i18n/en.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"@metadata": {
3-
"authors": [
4-
"brindosch"
5-
],
6-
"project" : "Hyperion WebUI",
7-
"locale": "en",
2+
"@metadata": {
3+
"authors": [
4+
"brindosch"
5+
],
6+
"project" : "Hyperion WebUI",
7+
"locale": "en",
88
"last-updated": "2016-11-30",
9-
"message-documentation": "qqq.json"
10-
},
9+
"message-documentation": "qqq.json"
10+
},
1111
"general_webui_title" : "Hyperion - Web Configuration",
1212
"general_country_de" : "Germany",
1313
"general_country_us" : "United States",
@@ -422,7 +422,8 @@
422422
"edt_conf_color_gammaGreen_expl" : "The gamma of green.",
423423
"edt_conf_color_gammaBlue_title" : "gamma blue",
424424
"edt_conf_color_gammaBlue_expl" : "The gamma of blue.",
425-
"edt_conf_color_brightnessMin_title" : "minimal brightness",
425+
"edt_conf_color_backlightThreshold_title" : "backlight threshold",
426+
"edt_conf_color_backlightColored_title" : "Colored backlight",
426427
"edt_conf_color_brightnessMin_expl" : "The minimum amount of brightness (backlight).",
427428
"edt_conf_color_brightness_title" : "maximal brightness",
428429
"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.",

assets/webconfig/js/wizard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ $(document).ready( function() {
347347
}
348348
if(step == 10)
349349
{
350-
updateWEditor(["brightnessMin"]);
350+
updateWEditor(["backlightThreshold"]);
351351
h = $.i18n('wiz_cc_minBright');
352352
if(withKodi)
353353
{

config/hyperion.config.json.commented

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
/// * 'gammaRed'/'gammaGreen'/'gammaBlue' : Gamma value for each channel
5050
/// * 'id' : The unique identifier of the channel adjustments (eg 'device_1')
5151
/// * 'id' : The unique identifier of the channel adjustments (eg 'device_1')
52-
/// * 'brightnessMin' : Minimum brightness (backlight)
52+
/// * 'backlightThreshold' : Minimum brightness (backlight)
53+
/// * 'backlightColored' : backlight with color, instead of white
5354
/// * 'brightness' : Between 0.0-0.5 the brightness is linearized (white is as bright as red, is as bright as yellow).
5455
/// 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)
5556
"color" :
@@ -71,7 +72,8 @@
7172
"gammaRed" : 1.0,
7273
"gammaGreen" : 1.0,
7374
"gammaBlue" : 1.0,
74-
"brightnessMin" : 0.0,
75+
"backlightThreshold" : 0.0,
76+
"backlightColored" : false,
7577
"brightness" : 0.5
7678
}
7779
]

config/hyperion.config.json.default

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"gammaRed" : 1.0,
3939
"gammaGreen" : 1.0,
4040
"gammaBlue" : 1.0,
41-
"brightnessMin" : 0.0,
41+
"backlightThreshold" : 0.0,
42+
"backlightColored" : false,
4243
"brightness" : 0.75
4344
}
4445
]

include/commandline/DoubleOption.h

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef HYPERION_DOUBLECOMMANDLINEOPTION_H
2-
#define HYPERION_DOUBLECOMMANDLINEOPTION_H
1+
#pragma once
32

43
#include <QtCore>
54
#include "ValidatorOption.h"
@@ -9,32 +8,38 @@ namespace commandline
98

109
class DoubleOption: public ValidatorOption
1110
{
12-
protected:
13-
double _double;
1411
public:
15-
DoubleOption(const QString &name,
16-
const QString &description = QString(),
17-
const QString &valueName = QString(),
18-
const QString &defaultValue = QString(),
19-
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
20-
: ValidatorOption(name, description, valueName, defaultValue)
21-
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
22-
DoubleOption(const QStringList &names,
23-
const QString &description = QString(),
24-
const QString &valueName = QString(),
25-
const QString &defaultValue = QString(),
26-
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
27-
: ValidatorOption(names, description, valueName, defaultValue)
28-
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
29-
DoubleOption(const QCommandLineOption &other,
30-
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
31-
: ValidatorOption(other)
32-
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
33-
34-
double getDouble(Parser &parser, bool *ok = 0);
35-
double *getDoublePtr(Parser &parser, bool *ok = 0);
12+
DoubleOption(const QString &name,
13+
const QString &description = QString(),
14+
const QString &valueName = QString(),
15+
const QString &defaultValue = QString(),
16+
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
17+
: ValidatorOption(name, description, valueName, defaultValue)
18+
{
19+
setValidator(new QDoubleValidator(minimum, maximum, decimals));
20+
}
21+
22+
DoubleOption(const QStringList &names,
23+
const QString &description = QString(),
24+
const QString &valueName = QString(),
25+
const QString &defaultValue = QString(),
26+
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
27+
: ValidatorOption(names, description, valueName, defaultValue)
28+
{
29+
setValidator(new QDoubleValidator(minimum, maximum, decimals));
30+
}
31+
32+
DoubleOption(const QCommandLineOption &other, double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
33+
: ValidatorOption(other)
34+
{
35+
setValidator(new QDoubleValidator(minimum, maximum, decimals));
36+
}
37+
38+
double getDouble(Parser &parser, bool *ok = 0);
39+
double *getDoublePtr(Parser &parser, bool *ok = 0);
40+
41+
protected:
42+
double _double;
3643
};
3744

3845
}
39-
40-
#endif //HYPERION_DOUBLECOMMANDLINEOPTION_H

include/commandline/SwitchOption.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef HYPERION_SWITCHCOMMANDLINEOPTION_H
2-
#define HYPERION_SWITCHCOMMANDLINEOPTION_H
1+
#pragma once
32

43
#include <QtCore>
54
#include "Option.h"
@@ -10,10 +9,8 @@ namespace commandline
109
template <class T>
1110
class SwitchOption: public Option
1211
{
13-
protected:
14-
QMap<QString, T> _switches;
1512
public:
16-
SwitchOption(const QString &name,
13+
SwitchOption(const QString &name,
1714
const QString &description = QString(),
1815
const QString &valueName = QString(),
1916
const QString &defaultValue = QString(),
@@ -38,8 +35,9 @@ class SwitchOption: public Option
3835
void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;}
3936
void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());}
4037
T & switchValue(Parser & parser){return _switches[value(parser).toLower()];}
38+
39+
protected:
40+
QMap<QString, T> _switches;
4141
};
4242

4343
}
44-
45-
#endif //HYPERION_SWITCHCOMMANDLINEOPTION_H

include/hyperion/Hyperion.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,6 @@ private slots:
368368
int _ledMAppingType;
369369

370370
int _configVersionId;
371+
372+
hyperion::Components _prevCompId;
371373
};

include/utils/RgbTransform.h

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ class RgbTransform
2020
/// @param gammaR The used red gamma
2121
/// @param gammaG The used green gamma
2222
/// @param gammab The used blue gamma
23-
/// @param brightnessLow The used lower brightness
23+
/// @param backlightThreshold The used lower brightness
24+
/// @param backlightColored use color in backlight
2425
/// @param brightnessHigh The used higher brightness
2526
///
26-
RgbTransform(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh);
27+
RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh);
2728

2829
///
2930
/// Destructor
@@ -39,19 +40,34 @@ class RgbTransform
3940
/// @return The current blue gamma value
4041
double getGammaB() const;
4142

42-
/// @param gamma New gamma value
43+
/// @param gammaR New red gamma value
44+
/// @param gammaG New green gamma value
45+
/// @param gammaB New blue gamma value
4346
void setGamma(double gammaR,double gammaG=-1, double gammaB=-1);
4447

4548
/// @return The current lower brightness
46-
double getBrightnessMin() const;
49+
double getBacklightThreshold() const;
4750

48-
/// @param gamma New lower brightness
49-
void setBrightnessMin(double brightness);
51+
/// @param backlightThreshold New lower brightness
52+
void setBacklightThreshold(double backlightThreshold);
5053

51-
/// @return The current lower brightness
54+
/// @return The current state
55+
bool getBacklightColored() const;
56+
57+
/// @param backlightColored en/disable colored backlight
58+
void setBacklightColored(bool backlightColored);
59+
60+
/// @return return state of backlight
61+
bool getBackLightEnabled() const;
62+
63+
/// @param enable en/disable backlight
64+
void setBackLightEnabled(bool enable);
65+
66+
67+
/// @return The current brightness
5268
double getBrightness() const;
5369

54-
/// @param gamma New lower brightness
70+
/// @param brightness New brightness
5571
void setBrightness(double brightness);
5672

5773
///
@@ -72,15 +88,17 @@ class RgbTransform
7288
/// @param gammaR The used red gamma
7389
/// @param gammaG The used green gamma
7490
/// @param gammab The used blue gamma
75-
/// @param brightnessLow The used lower brightness
91+
/// @param backlightThreshold The used lower brightness
92+
/// @param backlightColored en/disable color in backlight
7693
/// @param brightnessHigh The used higher brightness
7794
///
78-
void init(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh);
95+
void init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh);
7996

8097
/// (re)-initilize the color mapping
8198
void initializeMapping(); /// The saturation gain
8299

83-
double _brightnessLow;
100+
double _backlightThreshold;
101+
bool _backlightColored;
84102
double _brightnessHigh;
85103
double _sumBrightnessLow;
86104
double _sumBrightnessHigh;
@@ -93,4 +111,6 @@ class RgbTransform
93111
uint8_t _mappingR[256];
94112
uint8_t _mappingG[256];
95113
uint8_t _mappingB[256];
114+
115+
bool _backLightEnabled;
96116
};

libsrc/commandline/ColorOption.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@ using namespace commandline;
66

77
bool ColorOption::validate(Parser & parser, QString & value)
88
{
9-
// Check if we can create the color by name
10-
_color = QColor(value);
11-
if (_color.isValid()) {
12-
return true;
13-
}
9+
// Check if we can create the color by name
10+
_color = QColor(value);
11+
if (_color.isValid())
12+
{
13+
return true;
14+
}
1415

15-
// check if we can create the color by hex RRGGBB getColors
16-
_color = QColor(QString("#%1").arg(value));
17-
if (_color.isValid()) {
18-
return true;
19-
}
16+
// check if we can create the color by hex RRGGBB getColors
17+
_color = QColor(QString("#%1").arg(value));
18+
if (_color.isValid())
19+
{
20+
return true;
21+
}
2022

21-
if(!parser.isSet(*this)){
22-
// Return true if no value is available
23-
return true;
24-
}
23+
if(!parser.isSet(*this))
24+
{
25+
// Return true if no value is available
26+
return true;
27+
}
2528

26-
QStringList error;
27-
_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- "));
29+
_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- "));
2830

29-
return false;
31+
return false;
3032
}

0 commit comments

Comments
 (0)