From 8d3ff16037a5a0f893d52727b9644909ed9e8a66 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 27 Sep 2020 11:43:28 +0200 Subject: [PATCH] Add udpNotifier2 (JSON+HTTP, closes #1205 ) Added Loxone defines Fix missing timezones (#1201) --- wled00/colors.cpp | 26 ++- wled00/data/settings_sync.htm | 6 +- wled00/data/settings_time.htm | 6 +- wled00/fcn_declare.h | 8 +- wled00/html_settings.h | 332 +++++++++++++++++----------------- wled00/json.cpp | 59 ++---- wled00/lx_parser.cpp | 91 +++++----- wled00/set.cpp | 33 ++-- wled00/udp.cpp | 52 +++--- wled00/wled.cpp | 14 +- wled00/wled.h | 13 +- wled00/wled_eeprom.cpp | 15 +- wled00/xml.cpp | 5 +- 13 files changed, 326 insertions(+), 334 deletions(-) diff --git a/wled00/colors.cpp b/wled00/colors.cpp index f76499a0..361e3e06 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -62,7 +62,31 @@ void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY) colorRGBtoRGBW(col); } -void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb +void colorKtoRGB(uint16_t kelvin, byte* rgb) //white spectrum to rgb, calc +{ + float r = 0, g = 0, b = 0; + float temp = kelvin / 100; + if (temp <= 66) { + r = 255; + g = round(99.4708025861 * log(temp) - 161.1195681661); + if (temp <= 19) { + b = 0; + } else { + b = round(138.5177312231 * log((temp - 10)) - 305.0447927307); + } + } else { + r = round(329.698727446 * pow((temp - 60), -0.1332047592)); + g = round(288.1221695283 * pow((temp - 60), -0.0755148492)); + b = 255; + } + g += 15; //mod by Aircoookie, a bit less accurate but visibly less pinkish + rgb[0] = (uint8_t) constrain(r, 0, 255); + rgb[1] = (uint8_t) constrain(g, 0, 255); + rgb[2] = (uint8_t) constrain(b, 0, 255); + rgb[3] = 0; +} + +void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb, bins { //this is only an approximation using WS2812B with gamma correction enabled if (mired > 475) { diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 2f414ced..a144e76a 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -31,16 +31,14 @@ Infrared remote: IR info

WLED Broadcast

UDP Port:
+2nd Port:
Receive Brightness, Color, and Effects
Send notifications on direct change:
Send notifications on button press:
Send Alexa notifications:
Send Philips Hue change notifications:
Send Macro notifications:
-Send notifications twice: -

UDP Api

-Enable UDP Api:
-Port:
+Send notifications twice:
Reboot required to apply changes.

Realtime

Receive UDP realtime:

diff --git a/wled00/data/settings_time.htm b/wled00/data/settings_time.htm index c0231277..33b80af2 100644 --- a/wled00/data/settings_time.htm +++ b/wled00/data/settings_time.htm @@ -103,7 +103,11 @@ - + + + + +
UTC offset: seconds (max. 18 hours)
Current local time is unknown. diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 12d4854c..fb15e95a 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -30,6 +30,7 @@ void colorFromUint32(uint32_t in, bool secondary = false); void colorFromUint24(uint32_t in, bool secondary = false); void relativeChangeWhite(int8_t amount, byte lowerBoundary = 0); void colorHStoRGB(uint16_t hue, byte sat, byte* rgb); //hue, sat to rgb +void colorKtoRGB(uint16_t kelvin, byte* rgb); void colorCTtoRGB(uint16_t mired, byte* rgb); //white spectrum to rgb void colorXYtoRGB(float x, float y, byte* rgb); // only defined if huesync disabled TODO @@ -102,6 +103,10 @@ void updateInterfaces(uint8_t callMode); void handleTransitions(); void handleNightlight(); +//lx_parser.cpp +bool parseLx(int lxValue, byte* rgbw); +void parseLxJson(int lxValue, byte segId, bool secondary); + //mqtt.cpp bool initMqtt(); void publishMqtt(); @@ -223,7 +228,4 @@ void sappend(char stype, const char* key, int val); void sappends(char stype, const char* key, char* val); void getSettingsJS(byte subPage, char* dest); -//lx_parser.cpp -bool parseLx(int lxValue, int rgbw[4]); - #endif diff --git a/wled00/html_settings.h b/wled00/html_settings.h index b4b96a6f..258a2111 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -167,163 +167,163 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()====="; // Autogenerated from wled00/data/settings_ui.htm, do not edit!! const char PAGE_settings_ui[] PROGMEM = R"=====(UI Settings