From 11c7ffad4e5173f293692bfcd9d441c9bdf1180b Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 28 Nov 2021 04:01:58 +0100 Subject: [PATCH] Alexa and UDP sync CCT support --- platformio.ini | 7 +++++++ wled00/FX.h | 1 + wled00/FX_fcn.cpp | 14 ++++++++++++++ wled00/alexa.cpp | 15 ++++++++++++--- wled00/data/settings.htm | 2 +- wled00/html_settings.h | 2 +- wled00/json.cpp | 34 ++++++++++++---------------------- wled00/udp.cpp | 22 ++++++++++++++++++---- 8 files changed, 66 insertions(+), 31 deletions(-) diff --git a/platformio.ini b/platformio.ini index e700ed2b..37140330 100644 --- a/platformio.ini +++ b/platformio.ini @@ -434,6 +434,13 @@ board_build.ldscript = ${common.ldscript_2m512k} build_flags = ${common.build_flags_esp8266} -D LEDPIN=3 -D BTNPIN=2 -D IRPIN=5 -D WLED_MAX_BUTTONS=3 lib_deps = ${esp8266.lib_deps} +[env:athom7w] +board = esp_wroom_02 +platform = ${common.platform_wled_default} +board_build.ldscript = ${common.ldscript_2m512k} +build_flags = ${common.build_flags_esp8266} -D WLED_MAX_CCT_BLEND=0 -D BTNPIN=-1 -D IRPIN=-1 -D WLED_DISABLE_INFRARED +lib_deps = ${esp8266.lib_deps} + # ------------------------------------------------------------------------------ # travis test board configurations # ------------------------------------------------------------------------------ diff --git a/wled00/FX.h b/wled00/FX.h index b88d69bc..14e486b1 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -665,6 +665,7 @@ class WS2812FX { applyToAllSelected = true, setEffectConfig(uint8_t m, uint8_t s, uint8_t i, uint8_t p), checkSegmentAlignment(void), + hasCCTBus(void), // return true if the strip is being sent pixel updates isUpdating(void); diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index a232a2d3..b1e5e8bf 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -553,6 +553,20 @@ uint16_t WS2812FX::getLengthPhysical(void) { return len; } +bool WS2812FX::hasCCTBus(void) { + if (cctFromRgb && !correctWB) return false; + for (uint8_t b = 0; b < busses.getNumBusses(); b++) { + Bus *bus = busses.getBus(b); + if (bus == nullptr || bus->getLength()==0) break; + switch (bus->getType()) { + case TYPE_ANALOG_5CH: + case TYPE_ANALOG_2CH: + return true; + } + } + return false; +} + void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, uint8_t spacing) { if (n >= MAX_NUM_SEGMENTS) return; Segment& seg = _segments[n]; diff --git a/wled00/alexa.cpp b/wled00/alexa.cpp index 2e5b9b17..1b1d8b6d 100644 --- a/wled00/alexa.cpp +++ b/wled00/alexa.cpp @@ -73,17 +73,26 @@ void onAlexaChange(EspalexaDevice* dev) if (espalexaDevice->getColorMode() == EspalexaColorMode::ct) //shade of white { uint16_t ct = espalexaDevice->getCt(); - if (strip.isRgbw) - { + if (!ct) return; + uint16_t k = 1000000 / ct; //mireds to kelvin + + if (strip.hasCCTBus()) { + uint8_t segid = strip.getMainSegmentId(); + WS2812FX::Segment& seg = strip.getSegment(segid); + uint8_t cctPrev = seg.cct; + seg.setCCT(k, segid); + if (seg.cct != cctPrev) effectChanged = true; //send UDP + } else if (strip.isRgbw) { switch (ct) { //these values empirically look good on RGBW case 199: col[0]=255; col[1]=255; col[2]=255; col[3]=255; break; case 234: col[0]=127; col[1]=127; col[2]=127; col[3]=255; break; case 284: col[0]= 0; col[1]= 0; col[2]= 0; col[3]=255; break; case 350: col[0]=130; col[1]= 90; col[2]= 0; col[3]=255; break; case 383: col[0]=255; col[1]=153; col[2]= 0; col[3]=255; break; + default : colorKtoRGB(k, col); } } else { - colorCTtoRGB(ct, col); + colorKtoRGB(k, col); } } else { uint32_t color = espalexaDevice->getRGB(); diff --git a/wled00/data/settings.htm b/wled00/data/settings.htm index 66fcaeae..c8e2c983 100644 --- a/wled00/data/settings.htm +++ b/wled00/data/settings.htm @@ -20,7 +20,7 @@ border-radius: var(--h); font-size: 6vmin; height: var(--h); - width: 95%; + width: calc(100% - 40px); margin-top: 2vh; } diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 6df18570..2dec2e40 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -12,7 +12,7 @@ const char PAGE_settingsCss[] PROGMEM = R"=====(