Skip to content

Commit caab8e8

Browse files
authored
Adjustment merge + new brightness settings (#359)
* add new rgbtransform * activate rgbtransform * integrate new transform and gamma in adjustment, disable transform * fix brighness limit * advance upper and lower thresholds * start removing color transform * adjust configs/schema * implement json for new color adjustment * finish hyperion-remote extension for new adjustment settings * fix typos * rename luminance to brightness fix jsonapi for new adjustment * fix some bugs in adjustments * fix i18n * fix gamma via json * now brighness values goes from 0-1 with 0.5 is the default for all brighness is equal between the channels. less 0.5 all channels scaled down to new brighness, above 0.5 if possible channel gets brighter - but brighness is not equal between the channels anymore brighness value curve is now exponential instead of linear - this feels more natural * hslv cleanup
1 parent c433504 commit caab8e8

34 files changed

+641
-1803
lines changed

assets/webconfig/i18n/de.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@
314314
"edt_conf_color_cyan" : "Cyan",
315315
"edt_conf_color_magenta" : "Magenta",
316316
"edt_conf_color_yellow" : "Gelb",
317+
"edt_conf_color_gamma_red" : "Gamma rot",
318+
"edt_conf_color_gamma_green" : "Gamma grün",
319+
"edt_conf_color_gamma_blue" : "Gamma blau",
320+
"edt_conf_color_brightness_min" : "Minimale Helligkeit",
321+
"edt_conf_color_brightness" : "Maximale Helligkeit",
317322
"edt_conf_smooth_heading_title" : "Glättung",
318323
"edt_conf_smooth_type_title" : "Art",
319324
"edt_conf_smooth_type_expl" : "Algorithmus der Glättung.",

assets/webconfig/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@
315315
"edt_conf_color_cyan" : "cyan",
316316
"edt_conf_color_magenta" : "magenta",
317317
"edt_conf_color_yellow" : "yellow",
318+
"edt_conf_color_gamma_red" : "gamma red",
319+
"edt_conf_color_gamma_green" : "gamma green",
320+
"edt_conf_color_gamma_blue" : "gamma blue",
321+
"edt_conf_color_brightness_min" : "minimal brightness",
322+
"edt_conf_color_brightness" : "maximal brightness",
318323
"edt_conf_smooth_heading_title" : "Smoothing",
319324
"edt_conf_smooth_type_title" : "Type",
320325
"edt_conf_smooth_type_expl" : "Type of smoothing.",

config/hyperion.config.json.commented

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,37 +81,12 @@
8181
"blue" : [0,0,255],
8282
"cyan" : [0,255,255],
8383
"magenta" : [255,0,255],
84-
"yellow" : [255,255,0]
85-
}
86-
],
87-
"transform_enable" : true,
88-
"transform_v4l_only" : false,
89-
"transform" :
90-
[
91-
{
92-
"id" : "default",
93-
"leds" : "*",
94-
"hsl" :
95-
{
96-
"saturationGain" : 1.0000,
97-
"luminanceGain" : 1.0000,
98-
"luminanceMinimum" : 0.0000
99-
},
100-
"red" :
101-
{
102-
"threshold" : 0.0000,
103-
"gamma" : 2.5000
104-
},
105-
"green" :
106-
{
107-
"threshold" : 0.0000,
108-
"gamma" : 2.5000
109-
},
110-
"blue" :
111-
{
112-
"threshold" : 0.0000,
113-
"gamma" : 2.5000
114-
}
84+
"yellow" : [255,255,0],
85+
"gammaRed" : 1.0,
86+
"gammaGreen" : 1.0,
87+
"gammaBlue" : 1.0,
88+
"brightnessMin" : 0.0,
89+
"brightness" : 0.5
11590
}
11691
]
11792
},

config/hyperion.config.json.default

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,12 @@
3636
"blue" : [0,0,255],
3737
"cyan" : [0,255,255],
3838
"magenta" : [255,0,255],
39-
"yellow" : [255,255,0]
40-
}
41-
],
42-
"transform_enable" : true,
43-
"transform_v4l_only" : false,
44-
"transform" :
45-
[
46-
{
47-
"id" : "default",
48-
"leds" : "*",
49-
"hsl" :
50-
{
51-
"saturationGain" : 1.0000,
52-
"luminanceGain" : 1.0000,
53-
"luminanceMinimum" : 0.0000
54-
},
55-
"red" :
56-
{
57-
"threshold" : 0.0000,
58-
"gamma" : 2.5000
59-
},
60-
"green" :
61-
{
62-
"threshold" : 0.0000,
63-
"gamma" : 2.5000
64-
},
65-
"blue" :
66-
{
67-
"threshold" : 0.0000,
68-
"gamma" : 2.5000
69-
}
39+
"yellow" : [255,255,0],
40+
"gammaRed" : 1.0,
41+
"gammaGreen" : 1.0,
42+
"gammaBlue" : 1.0,
43+
"brightnessMin" : 0.0,
44+
"brightness" : 0.5
7045
}
7146
]
7247
},

include/hyperion/ColorAdjustment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// Utils includes
77
#include <utils/RgbChannelAdjustment.h>
8+
#include <utils/RgbTransform.h>
89

910
class ColorAdjustment
1011
{
@@ -29,4 +30,6 @@ class ColorAdjustment
2930
RgbChannelAdjustment _rgbMagentaAdjustment;
3031
/// The YELLOW (RGB-Channel) adjustment
3132
RgbChannelAdjustment _rgbYellowAdjustment;
33+
34+
RgbTransform _rgbTransform;
3235
};

include/hyperion/ColorTransform.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

include/hyperion/Hyperion.h

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
// Hyperion includes
2323
#include <hyperion/LedString.h>
2424
#include <hyperion/PriorityMuxer.h>
25-
#include <hyperion/ColorTransform.h>
2625
#include <hyperion/ColorAdjustment.h>
2726
#include <hyperion/MessageForwarder.h>
2827
#include <hyperion/ComponentRegister.h>
@@ -38,13 +37,9 @@
3837
// Forward class declaration
3938
class LedDevice;
4039
class LinearColorSmoothing;
41-
class ColorTransform;
40+
class RgbTransform;
4241
class EffectEngine;
43-
class HsvTransform;
44-
class HslTransform;
45-
class RgbChannelTransform;
4642
class RgbChannelAdjustment;
47-
class MultiColorTransform;
4843
class MultiColorAdjustment;
4944
class KODIVideoChecker;
5045
///
@@ -67,14 +62,6 @@ class Hyperion : public QObject
6762
BLACK, WHITE, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, INVALID
6863
};
6964

70-
///
71-
/// Enumeration of the possible color (color-channel) transforms
72-
///
73-
enum Transform
74-
{
75-
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
76-
};
77-
7865
///
7966
/// Destructor; cleans up resources
8067
///
@@ -216,23 +203,11 @@ public slots:
216203
///
217204
void setImage(int priority, const Image<ColorRgb> & image, int duration_ms);
218205

219-
///
220-
/// Returns the list with unique transform identifiers
221-
/// @return The list with transform identifiers
222-
///
223-
const std::vector<std::string> & getTransformIds() const;
224-
225206
///
226207
/// Returns the list with unique adjustment identifiers
227208
/// @return The list with adjustment identifiers
228209
///
229210
const std::vector<std::string> & getAdjustmentIds() const;
230-
231-
///
232-
/// Returns the ColorTransform with the given identifier
233-
/// @return The transform with the given identifier (or nullptr if the identifier does not exist)
234-
///
235-
ColorTransform * getTransform(const std::string& id);
236211

237212
///
238213
/// Returns the ColorAdjustment with the given identifier
@@ -246,9 +221,6 @@ public slots:
246221
///
247222
MessageForwarder * getForwarder();
248223

249-
/// Tell Hyperion that the transforms have changed and the leds need to be updated
250-
void transformsUpdated();
251-
252224
/// Tell Hyperion that the corrections have changed and the leds need to be updated
253225
void adjustmentsUpdated();
254226

@@ -295,14 +267,9 @@ public slots:
295267
static LedString createLedString(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
296268
static LedString createLedStringClone(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
297269

298-
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorTransformConfig);
299270
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig);
300-
static ColorTransform * createColorTransform(const QJsonObject & transformConfig);
301271
static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig);
302-
static HsvTransform * createHsvTransform(const QJsonObject & hsvConfig);
303-
static HslTransform * createHslTransform(const QJsonObject & hslConfig);
304-
static RgbChannelTransform * createRgbChannelTransform(const QJsonObject& colorConfig);
305-
static RgbChannelAdjustment * createRgbChannelCorrection(const QJsonObject& colorConfig);
272+
static RgbTransform * createRgbTransform(const QJsonObject& colorConfig);
306273
static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonArray& colorConfig, const RgbChannel color);
307274

308275
static LinearColorSmoothing * createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice);
@@ -349,9 +316,6 @@ private slots:
349316
/// The priority muxer
350317
PriorityMuxer _muxer;
351318

352-
/// The transformation from raw colors to led colors
353-
MultiColorTransform * _raw2ledTransform;
354-
355319
/// The adjustment from raw colors to led colors
356320
MultiColorAdjustment * _raw2ledAdjustment;
357321

@@ -393,12 +357,6 @@ private slots:
393357
/// flag for v4l color correction
394358
bool _colorAdjustmentV4Lonly;
395359

396-
/// flag for v4l color correction
397-
bool _colorTransformV4Lonly;
398-
399-
/// flag for color transform enable
400-
bool _transformEnabled;
401-
402360
/// flag for color adjustment enable
403361
bool _adjustmentEnabled;
404362

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,36 @@
44
#include <cstdint>
55

66
///
7-
/// Color transformation to adjust the saturation and value of a RGB color value
7+
/// Color transformation to adjust the saturation and luminance of a RGB color value
88
///
9-
class HsvTransform
9+
class ColorSys
1010
{
1111
public:
1212
///
13-
/// Default constructor
13+
/// Translates an RGB (red, green, blue) color to an HSL (hue, saturation, luminance) color
1414
///
15-
HsvTransform();
16-
17-
///
18-
/// Constructor
19-
///
20-
/// @param saturationGain The used saturation gain
21-
/// @param valueGain The used value gain
22-
///
23-
HsvTransform(double saturationGain, double valueGain);
24-
25-
///
26-
/// Destructor
27-
///
28-
~HsvTransform();
29-
30-
///
31-
/// Updates the saturation gain
32-
///
33-
/// @param saturationGain New saturationGain
34-
///
35-
void setSaturationGain(double saturationGain);
36-
37-
///
38-
/// Returns the saturation gain
39-
///
40-
/// @return The current Saturation gain
41-
///
42-
double getSaturationGain() const;
43-
44-
///
45-
/// Updates the value gain
46-
///
47-
/// @param valueGain New value gain
15+
/// @param[in] red The red RGB-component
16+
/// @param[in] green The green RGB-component
17+
/// @param[in] blue The blue RGB-component
18+
/// @param[out] hue The hue HSL-component
19+
/// @param[out] saturation The saturation HSL-component
20+
/// @param[out] luminance The luminance HSL-component
4821
///
49-
void setValueGain(double valueGain);
5022

51-
///
52-
/// Returns the value gain
53-
///
54-
/// @return The current value gain
55-
///
56-
double getValueGain() const;
23+
static void rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance);
5724

5825
///
59-
/// Apply the transform the the given RGB values.
26+
/// Translates an HSL (hue, saturation, luminance) color to an RGB (red, green, blue) color
6027
///
61-
/// @param red The red color component
62-
/// @param green The green color component
63-
/// @param blue The blue color component
64-
///
65-
/// @note The values are updated in place.
28+
/// @param[in] hue The hue HSL-component
29+
/// @param[in] saturation The saturation HSL-component
30+
/// @param[in] luminance The luminance HSL-component
31+
/// @param[out] red The red RGB-component
32+
/// @param[out] green The green RGB-component
33+
/// @param[out] blue The blue RGB-component
6634
///
67-
void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const;
6835

36+
static void hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue);
6937
///
7038
/// Translates an RGB (red, green, blue) color to an HSV (hue, saturation, value) color
7139
///
@@ -97,10 +65,4 @@ class HsvTransform
9765
/// number and scaled between 0 and 360
9866
///
9967
static void hsv2rgb(uint16_t hue, uint8_t saturation, uint8_t value, uint8_t & red, uint8_t & green, uint8_t & blue);
100-
101-
private:
102-
/// The saturation gain
103-
double _saturationGain;
104-
/// The value gain
105-
double _valueGain;
10668
};

0 commit comments

Comments
 (0)