From 53966d1885de9de3185dfa70091c4d89be908bd2 Mon Sep 17 00:00:00 2001 From: SJunkies <41368976+SJunkies@users.noreply.github.com> Date: Thu, 7 Feb 2019 11:37:53 +0100 Subject: [PATCH 1/5] Fixes PhilipsHue Brightness, ColorGamut+new Lights Hue RGB Color Conversion for Brightness is wrong! - use RGB to HSV instead of XYZ Space! For correct use, reset brightnessFactor back to 1.0 in config! - It was just a Workaround, not the Solution! Fixed wrong ColorGamut A/B/C Values + Added New Lamp Models: LCT015, LCT016, LCT024 --- .../leddevice/dev_net/LedDevicePhilipsHue.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp index 4a66afa9..d3fcc215 100755 --- a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp @@ -36,9 +36,10 @@ CiColor CiColor::rgbToCiColor(float red, float green, float blue, CiColorTriangl { 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 = - { cx, cy, Y }; + { cx, cy, bri }; // Check if the given XY value is within the color reach of our lamps. if (!isPointInLampsReach(xy, colorSpace)) { @@ -212,7 +213,7 @@ const std::set PhilipsHueLight::GAMUT_A_MODEL_IDS = const std::set PhilipsHueLight::GAMUT_B_MODEL_IDS = { "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" }; const std::set 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) : 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); colorSpace.red = - { 0.703f, 0.296f}; + { 0.704f, 0.296f}; colorSpace.green = { 0.2151f, 0.7106f}; colorSpace.blue = @@ -261,7 +262,7 @@ PhilipsHueLight::PhilipsHueLight(Logger* log, PhilipsHueBridge* bridge, unsigned colorSpace.red = { 0.675f, 0.322f}; colorSpace.green = - { 0.4091f, 0.518f}; + { 0.409f, 0.518f}; colorSpace.blue = { 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); colorSpace.red = - { 0.675f, 0.322f}; + { 0.6915f, 0.3083f}; colorSpace.green = - { 0.2151f, 0.7106f}; + { 0.17f, 0.7f}; colorSpace.blue = - { 0.167f, 0.04f}; + { 0.1532f, 0.0475f}; } else { From b048771e4aec5b785722daedf8163262babb1aff Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sun, 30 Dec 2018 23:18:59 +1100 Subject: [PATCH 2/5] Ws281x rpi pwm parsing fixes --- libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp index 4ba31511..d5e47109 100644 --- a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp @@ -20,9 +20,10 @@ bool LedDeviceWS281x::init(const QJsonObject &deviceConfig) { LedDevice::init(deviceConfig); - QString whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off"); + QString whiteAlgorithm = deviceConfig["whiteAlgorithm"].toString("white_off"); _whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm); Debug( _log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithm)); + Debug( _log, "rgbw : %d", deviceConfig["rgbw"].toBool(false) ); if (_whiteAlgorithm == RGBW::INVALID) { Error(_log, "unknown whiteAlgorithm %s", QSTRING_CSTR(whiteAlgorithm)); @@ -40,7 +41,7 @@ bool LedDeviceWS281x::init(const QJsonObject &deviceConfig) _led_string.channel[_channel].gpionum = deviceConfig["gpio"].toInt(18); _led_string.channel[_channel].count = deviceConfig["leds"].toInt(256); _led_string.channel[_channel].invert = deviceConfig["invert"].toInt(0); - _led_string.channel[_channel].strip_type = ((deviceConfig["rgbw"].toInt(0) == 1) ? SK6812_STRIP_GRBW : WS2811_STRIP_RGB); + _led_string.channel[_channel].strip_type = (deviceConfig["rgbw"].toBool(false) ? SK6812_STRIP_GRBW : WS2811_STRIP_RGB); _led_string.channel[_channel].brightness = 255; _led_string.channel[!_channel].gpionum = 0; @@ -49,6 +50,7 @@ bool LedDeviceWS281x::init(const QJsonObject &deviceConfig) _led_string.channel[!_channel].brightness = 0; _led_string.channel[!_channel].strip_type = WS2811_STRIP_RGB; + Debug( _log, "ws281x strip type : %d", _led_string.channel[_channel].strip_type ); if (ws2811_init(&_led_string) < 0) { From b77e7c4acd014202b673d0996cebbe4fa16ba91d Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 31 Dec 2018 16:09:21 +1100 Subject: [PATCH 3/5] sk6812 white_algorithm json parsing bug --- libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp b/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp index 2c98a5b6..f995ba9a 100644 --- a/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp +++ b/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp @@ -21,7 +21,7 @@ LedDevice* LedDeviceSk6812SPI::construct(const QJsonObject &deviceConfig) bool LedDeviceSk6812SPI::init(const QJsonObject &deviceConfig) { - QString whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off"); + QString whiteAlgorithm = deviceConfig["whiteAlgorithm"].toString("white_off"); _whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm); if (_whiteAlgorithm == RGBW::INVALID) From bceb255b7a160fab2ebda6b094ea922e95db8ca4 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 31 Dec 2018 16:10:25 +1100 Subject: [PATCH 4/5] Implemented warm white (and added cool white) RGBW white algorithms --- include/utils/RgbToRgbw.h | 8 +++++++- libsrc/utils/RgbToRgbw.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/include/utils/RgbToRgbw.h b/include/utils/RgbToRgbw.h index f1450427..87b76667 100644 --- a/include/utils/RgbToRgbw.h +++ b/include/utils/RgbToRgbw.h @@ -6,7 +6,13 @@ namespace RGBW { - enum WhiteAlgorithm { INVALID, SUBTRACT_MINIMUM, SUB_MIN_WARM_ADJUST, WHITE_OFF }; + enum WhiteAlgorithm { + INVALID, + SUBTRACT_MINIMUM, + SUB_MIN_WARM_ADJUST, + SUB_MIN_COOL_ADJUST, + WHITE_OFF + }; WhiteAlgorithm stringToWhiteAlgorithm(QString str); void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algorithm); diff --git a/libsrc/utils/RgbToRgbw.cpp b/libsrc/utils/RgbToRgbw.cpp index 7e5005c1..bb6aaa40 100755 --- a/libsrc/utils/RgbToRgbw.cpp +++ b/libsrc/utils/RgbToRgbw.cpp @@ -9,6 +9,7 @@ WhiteAlgorithm stringToWhiteAlgorithm(QString str) { if (str == "subtract_minimum") return SUBTRACT_MINIMUM; if (str == "sub_min_warm_adjust") return SUB_MIN_WARM_ADJUST; + if (str == "sub_min_cool_adjust") return SUB_MIN_COOL_ADJUST; if (str.isEmpty() || str == "white_off") return WHITE_OFF; return INVALID; } @@ -28,7 +29,31 @@ void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algori case SUB_MIN_WARM_ADJUST: { - Error(Logger::getInstance("RGBtoRGBW"), "white algorithm 'sub_min_warm_adjust' is not implemented yet." ); + // http://forum.garagecube.com/viewtopic.php?t=10178 + // warm white + float F1 = 0.274; + float F2 = 0.454; + float F3 = 2.333; + + output->white = qMin(input.red*F1,qMin(input.green*F2,input.blue*F3)); + output->red = input.red - output->white/F1; + output->green = input.green - output->white/F2; + output->blue = input.blue - output->white/F3; + break; + } + + case SUB_MIN_COOL_ADJUST: + { + // http://forum.garagecube.com/viewtopic.php?t=10178 + // cold white + float F1 = 0.299; + float F2 = 0.587; + float F3 = 0.114; + + output->white = qMin(input.red*F1,qMin(input.green*F2,input.blue*F3)); + output->red = input.red - output->white/F1; + output->green = input.green - output->white/F2; + output->blue = input.blue - output->white/F3; break; } From d3e447f4228e38b489832dd4b77b5fbc49afe083 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 31 Dec 2018 16:11:08 +1100 Subject: [PATCH 5/5] Add new white_algorithms to web UI --- assets/webconfig/i18n/cs.json | 3 ++- assets/webconfig/i18n/de.json | 1 + assets/webconfig/i18n/en.json | 3 ++- assets/webconfig/i18n/es.json | 3 ++- assets/webconfig/i18n/it.json | 1 + libsrc/leddevice/schemas/schema-sk6812spi.json | 4 ++-- libsrc/leddevice/schemas/schema-ws281x.json | 4 ++-- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/assets/webconfig/i18n/cs.json b/assets/webconfig/i18n/cs.json index 8cc269fb..4c22a882 100644 --- a/assets/webconfig/i18n/cs.json +++ b/assets/webconfig/i18n/cs.json @@ -294,7 +294,8 @@ "wiz_cc_btn_stop": "Stopnout video", "wiz_cc_summary": "Závěr nastavení. Během přehrávání videa můžete znovu měnit nebo otestovat hodnoty. Pokud jste hotovi, klikněte na tlačítko Uložit.", "edt_dev_enum_subtract_minimum": "Odčtěte minimum", - "edt_dev_enum_sub_min_warm_adjust": "Teplota barvy", + "edt_dev_enum_sub_min_cool_adjust": "Teplota barvy: cool", + "edt_dev_enum_sub_min_warm_adjust": "Teplota barvy: warm", "edt_dev_enum_white_off": "Bílá vypnutá", "edt_dev_general_heading_title": "Obecné nastavení", "edt_dev_general_name_title": "Název konfigurace", diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json index 9b6ee9fd..38308fc7 100644 --- a/assets/webconfig/i18n/de.json +++ b/assets/webconfig/i18n/de.json @@ -348,6 +348,7 @@ "wiz_cc_summary" : "Im folgenden eine Zusammenfassung deiner Einstellungen. Während du ein Video abspielst, kannst du hier weiter ausprobieren. Wenn du fertig bist, klicke auf speichern.", "edt_dev_auth_key_title" : "Aurora API Schlüssel", "edt_dev_enum_subtract_minimum" : "Subtrahiere minimum", + "edt_dev_enum_sub_min_cool_adjust" : "Minimale Anpassung: cool", "edt_dev_enum_sub_min_warm_adjust" : "Minimale Anpassung: warm", "edt_dev_enum_white_off" : "Weiß ist aus", "edt_dev_general_heading_title" : "Allgemeine Einstellungen", diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 9067151e..44d429a5 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -348,7 +348,8 @@ "wiz_cc_summary" : "A conclusion of your settings. During video playback, you could change or test values again. If you are done, click on save.", "edt_dev_auth_key_title" : "Aurora API Key", "edt_dev_enum_subtract_minimum" : "Substract minimum", - "edt_dev_enum_sub_min_warm_adjust" : "Min warm adjust", + "edt_dev_enum_sub_min_cool_adjust" : "Subtract cool white", + "edt_dev_enum_sub_min_warm_adjust" : "Subtract warm white", "edt_dev_enum_white_off" : "White off", "edt_dev_general_heading_title" : "General Settings", "edt_dev_general_name_title" : "Configuration name", diff --git a/assets/webconfig/i18n/es.json b/assets/webconfig/i18n/es.json index 74f42c70..afbd8a2c 100644 --- a/assets/webconfig/i18n/es.json +++ b/assets/webconfig/i18n/es.json @@ -294,6 +294,7 @@ "wiz_cc_btn_stop": "Parar vídeo", "wiz_cc_summary": "Una conclusión de su configuración. Durante la reproducción de vídeo, puede cambiar o probar valores de nuevo. Si está hecho, haga clic en guardar.", "edt_dev_enum_subtract_minimum": "Restar mínimo", + "edt_dev_enum_sub_min_cool_adjust": "Min. Ajuste fresco", "edt_dev_enum_sub_min_warm_adjust": "Min. Ajuste caliente", "edt_dev_enum_white_off": "Blanco apagado", "edt_dev_general_heading_title": "Configuración general", @@ -753,4 +754,4 @@ "edt_conf_enum_SECAM": "SECAM", "general_speech_it": "Italiano", "general_speech_cs": "Czech" -} \ No newline at end of file +} diff --git a/assets/webconfig/i18n/it.json b/assets/webconfig/i18n/it.json index 1a85d8cf..e78940ef 100644 --- a/assets/webconfig/i18n/it.json +++ b/assets/webconfig/i18n/it.json @@ -294,6 +294,7 @@ "wiz_cc_btn_stop": "Interrompi video", "wiz_cc_summary": "Conclusione delle tue impostazioni. Durante la riproduzione video puoi cambiare nuovamente i valori. Se hai finito clicca su salva.", "edt_dev_enum_subtract_minimum": "Sottrai minimo", + "edt_dev_enum_sub_min_cool_adjust": "Regolazione freddo min", "edt_dev_enum_sub_min_warm_adjust": "Regolazione calore min", "edt_dev_enum_white_off": "Bianco off", "edt_dev_general_heading_title": "Impostazioni Generali", diff --git a/libsrc/leddevice/schemas/schema-sk6812spi.json b/libsrc/leddevice/schemas/schema-sk6812spi.json index 8f3fc8ff..b8c02c29 100644 --- a/libsrc/leddevice/schemas/schema-sk6812spi.json +++ b/libsrc/leddevice/schemas/schema-sk6812spi.json @@ -23,10 +23,10 @@ "whiteAlgorithm": { "type": "string", "title":"edt_dev_spec_whiteLedAlgor_title", - "enum" : ["subtract_minimum","sub_min_warm_adjust","white_off"], + "enum" : ["subtract_minimum","sub_min_cool_adjust","sub_min_warm_adjust","white_off"], "default": "subtract_minimum", "options" : { - "enum_titles" : ["edt_dev_enum_subtract_minimum", "edt_dev_enum_sub_min_warm_adjust", "edt_dev_enum_white_off"] + "enum_titles" : ["edt_dev_enum_subtract_minimum", "edt_dev_enum_sub_min_cool_adjust","edt_dev_enum_sub_min_warm_adjust", "edt_dev_enum_white_off"] }, "propertyOrder" : 4 }, diff --git a/libsrc/leddevice/schemas/schema-ws281x.json b/libsrc/leddevice/schemas/schema-ws281x.json index bbf9206b..b190f400 100644 --- a/libsrc/leddevice/schemas/schema-ws281x.json +++ b/libsrc/leddevice/schemas/schema-ws281x.json @@ -35,10 +35,10 @@ "whiteAlgorithm": { "type": "string", "title":"edt_dev_spec_whiteLedAlgor_title", - "enum" : ["subtract_minimum","sub_min_warm_adjust","white_off"], + "enum" : ["subtract_minimum","sub_min_cool_adjust","sub_min_warm_adjust","white_off"], "default": "subtract_minimum", "options" : { - "enum_titles" : ["edt_dev_enum_subtract_minimum", "edt_dev_enum_sub_min_warm_adjust", "edt_dev_enum_white_off"] + "enum_titles" : ["edt_dev_enum_subtract_minimum", "edt_dev_enum_sub_min_cool_adjust","edt_dev_enum_sub_min_warm_adjust", "edt_dev_enum_white_off"] }, "propertyOrder" : 6 },