Merge pull request #533 from SJunkies/patch-1

Fixes PhilipsHue Brightness, ColorGamut + new Lights
This commit is contained in:
Rick164 2019-02-07 12:50:04 +01:00 committed by GitHub
commit 3432b67fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -36,9 +36,10 @@ CiColor CiColor::rgbToCiColor(float red, float green, float blue, CiColorTriangl
{ {
cy = 0.0f; cy = 0.0f;
} }
// Brightness is simply Y in the XYZ space. // 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 = CiColor xy =
{ cx, cy, Y }; { cx, cy, bri };
// Check if the given XY value is within the color reach of our lamps. // Check if the given XY value is within the color reach of our lamps.
if (!isPointInLampsReach(xy, colorSpace)) if (!isPointInLampsReach(xy, colorSpace))
{ {
@ -212,7 +213,7 @@ const std::set<QString> PhilipsHueLight::GAMUT_A_MODEL_IDS =
const std::set<QString> PhilipsHueLight::GAMUT_B_MODEL_IDS = const std::set<QString> PhilipsHueLight::GAMUT_B_MODEL_IDS =
{ "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" }; { "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" };
const std::set<QString> PhilipsHueLight::GAMUT_C_MODEL_IDS = const std::set<QString> PhilipsHueLight::GAMUT_C_MODEL_IDS =
{ "LLC020", "LST002", "LCT011", "LCT012", "LCT010", "LCT014" }; { "LLC020", "LST002", "LCT011", "LCT012", "LCT010", "LCT014", "LCT015", "LCT016", "LCT024" };
PhilipsHueLight::PhilipsHueLight(Logger* log, PhilipsHueBridge* bridge, unsigned int id, QJsonObject values) PhilipsHueLight::PhilipsHueLight(Logger* log, PhilipsHueBridge* bridge, unsigned int id, QJsonObject values)
: log(log) : log(log)
@ -249,7 +250,7 @@ PhilipsHueLight::PhilipsHueLight(Logger* log, PhilipsHueBridge* bridge, unsigned
{ {
Debug(log, "Recognized model id %s of light ID %d as gamut A", modelId.toStdString().c_str(), id); Debug(log, "Recognized model id %s of light ID %d as gamut A", modelId.toStdString().c_str(), id);
colorSpace.red = colorSpace.red =
{ 0.703f, 0.296f}; { 0.704f, 0.296f};
colorSpace.green = colorSpace.green =
{ 0.2151f, 0.7106f}; { 0.2151f, 0.7106f};
colorSpace.blue = colorSpace.blue =
@ -261,7 +262,7 @@ PhilipsHueLight::PhilipsHueLight(Logger* log, PhilipsHueBridge* bridge, unsigned
colorSpace.red = colorSpace.red =
{ 0.675f, 0.322f}; { 0.675f, 0.322f};
colorSpace.green = colorSpace.green =
{ 0.4091f, 0.518f}; { 0.409f, 0.518f};
colorSpace.blue = colorSpace.blue =
{ 0.167f, 0.04f}; { 0.167f, 0.04f};
} }
@ -269,11 +270,11 @@ PhilipsHueLight::PhilipsHueLight(Logger* log, PhilipsHueBridge* bridge, unsigned
{ {
Debug(log, "Recognized model id %s of light ID %d as gamut C", modelId.toStdString().c_str(), id); Debug(log, "Recognized model id %s of light ID %d as gamut C", modelId.toStdString().c_str(), id);
colorSpace.red = colorSpace.red =
{ 0.675f, 0.322f}; { 0.6915f, 0.3083f};
colorSpace.green = colorSpace.green =
{ 0.2151f, 0.7106f}; { 0.17f, 0.7f};
colorSpace.blue = colorSpace.blue =
{ 0.167f, 0.04f}; { 0.1532f, 0.0475f};
} }
else else
{ {