Fix - Philips Hue RGB Brightness Color Conversion (#799)

RGB to HSV/B Conversion after gamma correction

* Update LedDevicePhilipsHue.cpp

Hue RGB Color Conversion for Brightness is wrong! - use RGB to HSV instead of XYZ Space!
For correct use, reset brightnessFactor (if set) back to 1.0 in config! - It was just a Workaround, not the Solution!

* Update LedDevicePhilipsHue.cpp

sorry - wrong RGB vars used

* Update LedDevicePhilipsHue.cpp

change max value function to fmax

* RGB to HSV/B Conversion after gamma correction
This commit is contained in:
SJunkies 2018-12-19 22:29:36 +01:00 committed by Rick van Hattem
parent 1d125d8df8
commit 0b2ef9e3f4
1 changed files with 3 additions and 2 deletions

View File

@ -111,8 +111,9 @@ CiColor PhilipsHueLight::rgbToCiColor(float red, float green, float blue) {
if (std::isnan(cy)) {
cy = 0.0f;
// Brightness is simply Y in the XYZ space.
CiColor xy = { cx, cy, Y };
// RGB to HSV/B Conversion after gamma correction use V for brightness, not Y from XYZ Space.
float bri = fmax(fmax(r, g), b);
CiColor xy = { cx, cy, bri };
// Check if the given XY value is within the color reach of our lamps.
if (!isPointInLampsReach(xy)) {
// It seems the color is out of reach let's find the closes color we can produce with our lamp and send this XY value out.