Skip to content

Commit

Permalink
Merge pull request hyperion-project#2 from hyperion-project/master
Browse files Browse the repository at this point in the history
pull
  • Loading branch information
janpfischer committed Feb 10, 2019
2 parents 40f4fda + 4625a64 commit 03a7018
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 20 deletions.
3 changes: 2 additions & 1 deletion assets/webconfig/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions assets/webconfig/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion assets/webconfig/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -753,4 +754,4 @@
"edt_conf_enum_SECAM": "SECAM",
"general_speech_it": "Italiano",
"general_speech_cs": "Czech"
}
}
1 change: 1 addition & 0 deletions assets/webconfig/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion include/utils/RgbToRgbw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 9 additions & 8 deletions libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -212,7 +213,7 @@ const std::set<QString> PhilipsHueLight::GAMUT_A_MODEL_IDS =
const std::set<QString> PhilipsHueLight::GAMUT_B_MODEL_IDS =
{ "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" };
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)
: log(log)
Expand Down Expand Up @@ -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 =
Expand All @@ -261,19 +262,19 @@ 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};
}
else if (GAMUT_C_MODEL_IDS.find(modelId) != GAMUT_C_MODEL_IDS.end())
{
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
{
Expand Down
6 changes: 4 additions & 2 deletions libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libsrc/leddevice/schemas/schema-sk6812spi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
4 changes: 2 additions & 2 deletions libsrc/leddevice/schemas/schema-ws281x.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
27 changes: 26 additions & 1 deletion libsrc/utils/RgbToRgbw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down

0 comments on commit 03a7018

Please sign in to comment.