Merge pull request #535 from penfold42/rgbw2

Rgbw fixes
This commit is contained in:
Rick164 2019-02-08 14:26:23 +01:00 committed by GitHub
commit 4625a64ddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 50 additions and 12 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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);

View File

@ -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)
{

View File

@ -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)

View File

@ -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
},

View File

@ -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
},

View File

@ -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;
}