2020-09-27 11:37:16 +02:00
|
|
|
#include "wled.h"
|
|
|
|
|
2022-12-18 11:07:32 +01:00
|
|
|
#ifdef WLED_ENABLE_LOXONE
|
|
|
|
|
2020-09-27 11:43:28 +02:00
|
|
|
/*
|
|
|
|
* Parser for Loxone formats
|
|
|
|
*/
|
|
|
|
bool parseLx(int lxValue, byte rgbw[4])
|
2020-09-27 11:37:16 +02:00
|
|
|
{
|
2020-09-27 11:43:28 +02:00
|
|
|
DEBUG_PRINT(F("LX: Lox = "));
|
|
|
|
DEBUG_PRINTLN(lxValue);
|
|
|
|
|
2020-09-27 11:37:16 +02:00
|
|
|
bool ok = false;
|
2020-09-27 11:43:28 +02:00
|
|
|
float lxRed = 0, lxGreen = 0, lxBlue = 0;
|
2020-09-27 11:37:16 +02:00
|
|
|
|
2023-01-06 09:24:29 +01:00
|
|
|
if (lxValue < 200000000) {
|
2020-09-27 11:37:16 +02:00
|
|
|
// Loxone RGB
|
|
|
|
ok = true;
|
|
|
|
lxRed = round((lxValue % 1000) * 2.55);
|
|
|
|
lxGreen = round(((lxValue / 1000) % 1000) * 2.55);
|
|
|
|
lxBlue = round(((lxValue / 1000000) % 1000) * 2.55);
|
2023-01-06 09:24:29 +01:00
|
|
|
} else if ((lxValue >= 200000000) && (lxValue <= 201006500)) {
|
2020-09-27 11:37:16 +02:00
|
|
|
// Loxone Lumitech
|
|
|
|
ok = true;
|
|
|
|
float tmpBri = floor((lxValue - 200000000) / 10000); ;
|
|
|
|
uint16_t ct = (lxValue - 200000000) - (((uint8_t)tmpBri) * 10000);
|
|
|
|
|
|
|
|
tmpBri *= 2.55;
|
2021-02-27 01:16:06 +01:00
|
|
|
tmpBri = constrain(tmpBri, 0, 255);
|
2020-09-27 11:43:28 +02:00
|
|
|
|
|
|
|
colorKtoRGB(ct, rgbw);
|
|
|
|
lxRed = rgbw[0]; lxGreen = rgbw[1]; lxBlue = rgbw[2];
|
2020-09-27 11:37:16 +02:00
|
|
|
|
|
|
|
lxRed *= (tmpBri/255);
|
|
|
|
lxGreen *= (tmpBri/255);
|
|
|
|
lxBlue *= (tmpBri/255);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ok) {
|
2020-09-27 11:43:28 +02:00
|
|
|
rgbw[0] = (uint8_t) constrain(lxRed, 0, 255);
|
|
|
|
rgbw[1] = (uint8_t) constrain(lxGreen, 0, 255);
|
|
|
|
rgbw[2] = (uint8_t) constrain(lxBlue, 0, 255);
|
2020-09-27 11:37:16 +02:00
|
|
|
rgbw[3] = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-27 11:43:28 +02:00
|
|
|
void parseLxJson(int lxValue, byte segId, bool secondary)
|
|
|
|
{
|
|
|
|
if (secondary) {
|
|
|
|
DEBUG_PRINT(F("LY: Lox secondary = "));
|
|
|
|
} else {
|
|
|
|
DEBUG_PRINT(F("LX: Lox primary = "));
|
|
|
|
}
|
|
|
|
DEBUG_PRINTLN(lxValue);
|
|
|
|
byte rgbw[] = {0,0,0,0};
|
|
|
|
if (parseLx(lxValue, rgbw)) {
|
|
|
|
if (bri == 0) {
|
|
|
|
DEBUG_PRINTLN(F("LX: turn on"));
|
|
|
|
toggleOnOff();
|
|
|
|
}
|
|
|
|
bri = 255;
|
|
|
|
nightlightActive = false; //always disable nightlight when toggling
|
2022-12-18 11:07:32 +01:00
|
|
|
DEBUG_PRINT(F("LX: segment "));
|
|
|
|
DEBUG_PRINTLN(segId);
|
|
|
|
strip.getSegment(segId).setColor(secondary, RGBW32(rgbw[0], rgbw[1], rgbw[2], rgbw[3])); // legacy values handled as well in json.cpp by stateUpdated()
|
2020-09-27 11:43:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-18 11:07:32 +01:00
|
|
|
#endif
|