Merge branch 'merge-master' of github.com:blazoncek/WLED into merge-master

This commit is contained in:
Blaz Kristan 2022-02-24 16:57:36 +01:00
commit 110a75ba0b
17 changed files with 129 additions and 113 deletions

View File

@ -45,7 +45,7 @@ body:
attributes: attributes:
label: What version of WLED? label: What version of WLED?
description: You can find this in by going to Config -> Security & Updates -> Scroll to Bottom. Copy and paste the entire line after "Server message" description: You can find this in by going to Config -> Security & Updates -> Scroll to Bottom. Copy and paste the entire line after "Server message"
placeholder: "e.g. WLED 0.13.0-b4 (build 2110110)" placeholder: "e.g. WLED 0.13.0-b7 (build 2202222)"
validations: validations:
required: true required: true
- type: dropdown - type: dropdown

View File

@ -2,6 +2,12 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2202222
- Version bump to 0.13.0-b7 "Toki"
- Fixed HTTP API commands not applying to all selected segments in some conditions
- Blynk support is not compiled in by default on ESP32 builds
#### Build 2202210 #### Build 2202210
- Fixed HTTP API commands not applying to all selected segments if called from JSON - Fixed HTTP API commands not applying to all selected segments if called from JSON

View File

@ -12,7 +12,7 @@
; default_envs = travis_esp8266, travis_esp32 ; default_envs = travis_esp8266, travis_esp32
# Release binaries # Release binaries
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s2_saola, esp32c3 default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32_eth_ota1mapp, esp32s2_saola, esp32c3
# Build everything # Build everything
; default_envs = esp32dev, esp8285_4CH_MagicHome, codm-controller-0.6-rev2, codm-controller-0.6, esp32s2_saola, d1_mini_5CH_Shojo_PCB, d1_mini, sp501e, travis_esp8266, travis_esp32, nodemcuv2, esp32_eth, anavi_miracle_controller, esp07, esp01_1m_full, m5atom, h803wf, d1_mini_ota, heltec_wifi_kit_8, esp8285_H801, d1_mini_debug, wemos_shield_esp32, elekstube_ips ; default_envs = esp32dev, esp8285_4CH_MagicHome, codm-controller-0.6-rev2, codm-controller-0.6, esp32s2_saola, d1_mini_5CH_Shojo_PCB, d1_mini, sp501e, travis_esp8266, travis_esp32, nodemcuv2, esp32_eth, anavi_miracle_controller, esp07, esp01_1m_full, m5atom, h803wf, d1_mini_ota, heltec_wifi_kit_8, esp8285_H801, d1_mini_debug, wemos_shield_esp32, elekstube_ips
@ -35,6 +35,7 @@ default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, esp32dev, esp32_eth, esp32s
; default_envs = wemos_shield_esp32 ; default_envs = wemos_shield_esp32
; default_envs = m5atom ; default_envs = m5atom
; default_envs = esp32_eth ; default_envs = esp32_eth
; default_envs = esp32_eth_ota1mapp
; default_envs = esp32s2_saola ; default_envs = esp32s2_saola
src_dir = ./wled00 src_dir = ./wled00
@ -265,7 +266,9 @@ lib_deps = ${esp8266.lib_deps}
[env:esp8266_2m] [env:esp8266_2m]
board = esp_wroom_02 board = esp_wroom_02
platform = ${common.platform_wled_default} platform = ${common.platform_wled_default}
platform_packages = ${common.platform_packages}
board_build.ldscript = ${common.ldscript_2m512k} board_build.ldscript = ${common.ldscript_2m512k}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP02 build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP02
lib_deps = ${esp8266.lib_deps} lib_deps = ${esp8266.lib_deps}
@ -320,7 +323,7 @@ lib_deps = ${esp8266.lib_deps}
board = esp32dev board = esp32dev
platform = ${esp32.platform} platform = ${esp32.platform}
build_unflags = ${common.build_unflags} build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32 #-D WLED_DISABLE_BROWNOUT_DET build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32 -D WLED_DISABLE_BLYNK #-D WLED_DISABLE_BROWNOUT_DET
lib_deps = ${esp32.lib_deps} lib_deps = ${esp32.lib_deps}
monitor_filters = esp32_exception_decoder monitor_filters = esp32_exception_decoder
board_build.partitions = ${esp32.default_partitions} board_build.partitions = ${esp32.default_partitions}
@ -334,6 +337,11 @@ build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32_Ethernet -D
lib_deps = ${esp32.lib_deps} lib_deps = ${esp32.lib_deps}
board_build.partitions = ${esp32.default_partitions} board_build.partitions = ${esp32.default_partitions}
# ESP32 ETH build that fits in old 1M app space (disables Blynk, Cronixie, and Hue sync)
[env:esp32_eth_ota1mapp]
extends = env:esp32_eth
build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32_Ethernet_OTA -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE -D WLED_DISABLE_HUESYNC
[env:esp32s2_saola] [env:esp32s2_saola]
board = esp32-s2-saola-1 board = esp32-s2-saola-1
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2/platform-tasmota-espressif32-2.0.2.zip platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2/platform-tasmota-espressif32-2.0.2.zip

View File

@ -461,7 +461,7 @@ public:
void lampUdated() { void lampUdated() {
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification) //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa // 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
//setValuesFromMainSeg(); //to make transition work on main segment (should no longer be required) //setValuesFromFirstSelectedSeg(); //to make transition work on main segment (should no longer be required)
stateUpdated(CALL_MODE_BUTTON); stateUpdated(CALL_MODE_BUTTON);
updateInterfaces(CALL_MODE_BUTTON); updateInterfaces(CALL_MODE_BUTTON);
} }

View File

@ -622,6 +622,7 @@ class WS2812FX {
setMode(uint8_t segid, uint8_t m), setMode(uint8_t segid, uint8_t m),
setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0), setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
setColor(uint8_t slot, uint32_t c), setColor(uint8_t slot, uint32_t c),
setCCT(uint16_t k),
setBrightness(uint8_t b), setBrightness(uint8_t b),
setRange(uint16_t i, uint16_t i2, uint32_t col), setRange(uint16_t i, uint16_t i2, uint32_t col),
setShowCallback(show_callback cb), setShowCallback(show_callback cb),
@ -660,6 +661,7 @@ class WS2812FX {
getPaletteCount(void), getPaletteCount(void),
getMaxSegments(void), getMaxSegments(void),
getActiveSegmentsNum(void), getActiveSegmentsNum(void),
getFirstSelectedSegId(void),
getMainSegmentId(void), getMainSegmentId(void),
getLastActiveSegmentId(void), getLastActiveSegmentId(void),
getTargetFps(void), getTargetFps(void),
@ -689,11 +691,11 @@ class WS2812FX {
currentColor(uint32_t colorNew, uint8_t tNr), currentColor(uint32_t colorNew, uint8_t tNr),
gamma32(uint32_t), gamma32(uint32_t),
getLastShow(void), getLastShow(void),
getPixelColor(uint16_t), getPixelColor(uint16_t);
getColor(void);
WS2812FX::Segment WS2812FX::Segment
&getSegment(uint8_t n), &getSegment(uint8_t n),
&getFirstSelectedSeg(void),
&getMainSegment(void); &getMainSegment(void);
WS2812FX::Segment* WS2812FX::Segment*

View File

@ -409,6 +409,15 @@ void WS2812FX::setColor(uint8_t slot, uint32_t c) {
} }
} }
void WS2812FX::setCCT(uint16_t k) {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isActive() && _segments[i].isSelected()) {
_segments[i].setCCT(k, i);
}
}
}
void WS2812FX::setBrightness(uint8_t b) { void WS2812FX::setBrightness(uint8_t b) {
if (gammaCorrectBri) b = gamma8(b); if (gammaCorrectBri) b = gamma8(b);
if (_brightness == b) return; if (_brightness == b) return;
@ -431,18 +440,19 @@ uint8_t WS2812FX::getMaxSegments(void) {
return MAX_NUM_SEGMENTS; return MAX_NUM_SEGMENTS;
} }
void WS2812FX::setMainSegmentId(uint8_t n) { uint8_t WS2812FX::getFirstSelectedSegId(void)
if (n >= MAX_NUM_SEGMENTS) return; {
if (_segments[n].isActive() && _segments[n].isSelected()) {
_mainSegment = n; return;
}
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{ {
if (_segments[i].isActive() && _segments[i].isSelected()) { if (_segments[i].isActive() && _segments[i].isSelected()) return i;
_mainSegment = i; return;
} }
} // if none selected, use the main segment
//if none selected, use supplied n if active, or first active return getMainSegmentId();
}
void WS2812FX::setMainSegmentId(uint8_t n) {
if (n >= MAX_NUM_SEGMENTS) return;
//use supplied n if active, or first active
if (_segments[n].isActive()) { if (_segments[n].isActive()) {
_mainSegment = n; return; _mainSegment = n; return;
} }
@ -476,10 +486,6 @@ uint8_t WS2812FX::getActiveSegmentsNum(void) {
return c; return c;
} }
uint32_t WS2812FX::getColor(void) {
return _segments[getMainSegmentId()].colors[0];
}
uint32_t WS2812FX::getPixelColor(uint16_t i) uint32_t WS2812FX::getPixelColor(uint16_t i)
{ {
i = realPixelIndex(i); i = realPixelIndex(i);
@ -501,6 +507,10 @@ WS2812FX::Segment& WS2812FX::getSegment(uint8_t id) {
return _segments[id]; return _segments[id];
} }
WS2812FX::Segment& WS2812FX::getFirstSelectedSeg(void) {
return _segments[getFirstSelectedSegId()];
}
WS2812FX::Segment& WS2812FX::getMainSegment(void) { WS2812FX::Segment& WS2812FX::getMainSegment(void) {
return _segments[getMainSegmentId()]; return _segments[getMainSegmentId()];
} }
@ -630,7 +640,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
delete[] seg.name; delete[] seg.name;
seg.name = nullptr; seg.name = nullptr;
} }
//if main segment is deleted, set first selected/active as main segment // if main segment is deleted, set first active as main segment
if (n == _mainSegment) setMainSegmentId(0); if (n == _mainSegment) setMainSegmentId(0);
return; return;
} }

View File

@ -72,36 +72,32 @@ void onAlexaChange(EspalexaDevice* dev)
{ {
if (espalexaDevice->getColorMode() == EspalexaColorMode::ct) //shade of white if (espalexaDevice->getColorMode() == EspalexaColorMode::ct) //shade of white
{ {
byte rgbw[4];
uint16_t ct = espalexaDevice->getCt(); uint16_t ct = espalexaDevice->getCt();
if (!ct) return; if (!ct) return;
uint16_t k = 1000000 / ct; //mireds to kelvin uint16_t k = 1000000 / ct; //mireds to kelvin
if (strip.hasCCTBus()) { if (strip.hasCCTBus()) {
uint8_t segid = strip.getMainSegmentId(); strip.setCCT(k);
WS2812FX::Segment& seg = strip.getSegment(segid); rgbw[0]= 0; rgbw[1]= 0; rgbw[2]= 0; rgbw[3]= 255;
seg.setCCT(k, segid);
col[0]= 0; col[1]= 0; col[2]= 0; col[3]= 255;
} else if (strip.hasWhiteChannel()) { } else if (strip.hasWhiteChannel()) {
switch (ct) { //these values empirically look good on RGBW 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 199: rgbw[0]=255; rgbw[1]=255; rgbw[2]=255; rgbw[3]=255; break;
case 234: col[0]=127; col[1]=127; col[2]=127; col[3]=255; break; case 234: rgbw[0]=127; rgbw[1]=127; rgbw[2]=127; rgbw[3]=255; break;
case 284: col[0]= 0; col[1]= 0; col[2]= 0; col[3]=255; break; case 284: rgbw[0]= 0; rgbw[1]= 0; rgbw[2]= 0; rgbw[3]=255; break;
case 350: col[0]=130; col[1]= 90; col[2]= 0; col[3]=255; break; case 350: rgbw[0]=130; rgbw[1]= 90; rgbw[2]= 0; rgbw[3]=255; break;
case 383: col[0]=255; col[1]=153; col[2]= 0; col[3]=255; break; case 383: rgbw[0]=255; rgbw[1]=153; rgbw[2]= 0; rgbw[3]=255; break;
default : colorKtoRGB(k, col); default : colorKtoRGB(k, rgbw);
} }
} else { } else {
colorKtoRGB(k, col); colorKtoRGB(k, rgbw);
} }
strip.setColor(0, RGBW32(rgbw[0], rgbw[1], rgbw[2], rgbw[3]));
} else { } else {
uint32_t color = espalexaDevice->getRGB(); uint32_t color = espalexaDevice->getRGB();
strip.setColor(0, color);
col[0] = ((color >> 16) & 0xFF);
col[1] = ((color >> 8) & 0xFF);
col[2] = ( color & 0xFF);
col[3] = 0;
} }
colorUpdated(CALL_MODE_ALEXA); stateUpdated(CALL_MODE_ALEXA);
} }
} }

View File

@ -142,7 +142,7 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient = 0);
#endif #endif
//led.cpp //led.cpp
void setValuesFromMainSeg(); void setValuesFromFirstSelectedSeg();
void resetTimebase(); void resetTimebase();
void toggleOnOff(); void toggleOnOff();
void applyBri(); void applyBri();

View File

@ -189,7 +189,7 @@ void sendImprovInfoResponse() {
out[11] = 4; //Firmware len ("WLED") out[11] = 4; //Firmware len ("WLED")
out[12] = 'W'; out[13] = 'L'; out[14] = 'E'; out[15] = 'D'; out[12] = 'W'; out[13] = 'L'; out[14] = 'E'; out[15] = 'D';
uint8_t lengthSum = 17; uint8_t lengthSum = 17;
uint8_t vlen = sprintf_P(out+lengthSum,PSTR("0.13.0-b6/%i"),VERSION); uint8_t vlen = sprintf_P(out+lengthSum,PSTR("0.13.1-bl7/%i"),VERSION);
out[16] = vlen; lengthSum += vlen; out[16] = vlen; lengthSum += vlen;
uint8_t hlen = 7; uint8_t hlen = 7;
#ifdef ESP8266 #ifdef ESP8266

View File

@ -95,7 +95,7 @@ void changeEffect(uint8_t fx)
strip.setMode(i, fx); strip.setMode(i, fx);
} }
} else { } else {
strip.setMode(strip.getMainSegmentId(), fx); strip.setMode(strip.getFirstSelectedSegId(), fx);
} }
effectCurrent = fx; effectCurrent = fx;
stateChanged = true; stateChanged = true;
@ -110,7 +110,7 @@ void changePalette(uint8_t pal)
seg.palette = pal; seg.palette = pal;
} }
} else { } else {
strip.getSegment(strip.getMainSegmentId()).palette = pal; strip.getFirstSelectedSeg().palette = pal;
} }
effectPalette = pal; effectPalette = pal;
stateChanged = true; stateChanged = true;
@ -128,7 +128,7 @@ void changeEffectSpeed(int8_t amount)
seg.speed = effectSpeed; seg.speed = effectSpeed;
} }
} else { } else {
strip.getSegment(strip.getMainSegmentId()).speed = effectSpeed; strip.getFirstSelectedSeg().speed = effectSpeed;
} }
} else { // if Effect == "solid Color", change the hue of the primary color } else { // if Effect == "solid Color", change the hue of the primary color
CRGB fastled_col; CRGB fastled_col;
@ -151,7 +151,7 @@ void changeEffectSpeed(int8_t amount)
seg.colors[0] = RGBW32(col[0], col[1], col[2], col[3]); seg.colors[0] = RGBW32(col[0], col[1], col[2], col[3]);
} }
} else { } else {
strip.getSegment(strip.getMainSegmentId()).colors[0] = RGBW32(col[0], col[1], col[2], col[3]); strip.getFirstSelectedSeg().colors[0] = RGBW32(col[0], col[1], col[2], col[3]);
} }
} }
stateChanged = true; stateChanged = true;
@ -173,7 +173,7 @@ void changeEffectIntensity(int8_t amount)
seg.intensity = effectIntensity; seg.intensity = effectIntensity;
} }
} else { } else {
strip.getSegment(strip.getMainSegmentId()).speed = effectIntensity; strip.getFirstSelectedSeg().speed = effectIntensity;
} }
} else { // if Effect == "solid Color", change the saturation of the primary color } else { // if Effect == "solid Color", change the saturation of the primary color
CRGB fastled_col; CRGB fastled_col;
@ -194,7 +194,7 @@ void changeEffectIntensity(int8_t amount)
seg.colors[0] = RGBW32(col[0], col[1], col[2], col[3]); seg.colors[0] = RGBW32(col[0], col[1], col[2], col[3]);
} }
} else { } else {
strip.getSegment(strip.getMainSegmentId()).colors[0] = RGBW32(col[0], col[1], col[2], col[3]); strip.getFirstSelectedSeg().colors[0] = RGBW32(col[0], col[1], col[2], col[3]);
} }
} }
stateChanged = true; stateChanged = true;
@ -224,7 +224,7 @@ void changeColor(uint32_t c, int16_t cct=-1)
if (isCCT && cct >= 0) seg.setCCT(cct, i); if (isCCT && cct >= 0) seg.setCCT(cct, i);
} }
} else { } else {
byte i = strip.getMainSegmentId(); byte i = strip.getFirstSelectedSegId();
WS2812FX::Segment& seg = strip.getSegment(i); WS2812FX::Segment& seg = strip.getSegment(i);
byte capabilities = seg.getLightCapabilities(); byte capabilities = seg.getLightCapabilities();
uint32_t mask = 0; uint32_t mask = 0;
@ -238,7 +238,7 @@ void changeColor(uint32_t c, int16_t cct=-1)
} else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black } else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black
if (isCCT && cct >= 0) seg.setCCT(cct, i); if (isCCT && cct >= 0) seg.setCCT(cct, i);
} }
setValuesFromMainSeg(); //make transitions graceful setValuesFromFirstSelectedSeg(); //make transitions graceful
stateChanged = true; stateChanged = true;
} }

View File

@ -211,8 +211,10 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
} else if (!elem["frz"] && iarr.isNull()) { //return to regular effect } else if (!elem["frz"] && iarr.isNull()) { //return to regular effect
seg.setOption(SEG_OPTION_FREEZE, false); seg.setOption(SEG_OPTION_FREEZE, false);
} }
//send UDP if not in preset and something changed that is not just selection // send UDP if not in preset and something changed that is not just selection
if (!presetId && (seg.differs(prev) & 0x7F)) stateChanged = true; //if (!presetId && (seg.differs(prev) & 0x7F)) stateChanged = true;
// send UDP if something changed that is not just selection
if (seg.differs(prev) & 0x7F) stateChanged = true;
return; return;
} }
@ -315,9 +317,6 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
} }
} }
//refresh main segment (ensure it is selected, if there are any selected segments)
strip.setMainSegmentId(strip.getMainSegmentId());
#ifndef WLED_DISABLE_CRONIXIE #ifndef WLED_DISABLE_CRONIXIE
if (root["nx"].is<const char*>()) { if (root["nx"].is<const char*>()) {
strncpy(cronixieDisplay, root["nx"], 6); strncpy(cronixieDisplay, root["nx"], 6);

View File

@ -3,9 +3,9 @@
/* /*
* LED methods * LED methods
*/ */
void setValuesFromMainSeg() void setValuesFromFirstSelectedSeg()
{ {
WS2812FX::Segment& seg = strip.getMainSegment(); WS2812FX::Segment& seg = strip.getFirstSelectedSeg();
col[0] = R(seg.colors[0]); col[0] = R(seg.colors[0]);
col[1] = G(seg.colors[0]); col[1] = G(seg.colors[0]);
col[2] = B(seg.colors[0]); col[2] = B(seg.colors[0]);
@ -21,23 +21,25 @@ void setValuesFromMainSeg()
} }
//applies global legacy values (col, colSec, effectCurrent...) // applies global legacy values (col, colSec, effectCurrent...)
// problem: if the first selected segment already has the value to be set, other selected segments are not updated
void applyValuesToSelectedSegs() void applyValuesToSelectedSegs()
{ {
//copy of main segment to tell if value was updated // copy of first selected segment to tell if value was updated
WS2812FX::Segment mainsegPrev = strip.getMainSegment(); uint8_t firstSel = strip.getFirstSelectedSegId();
WS2812FX::Segment selsegPrev = strip.getSegment(firstSel);
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) { for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
WS2812FX::Segment& seg = strip.getSegment(i); WS2812FX::Segment& seg = strip.getSegment(i);
if (i != strip.getMainSegmentId() && (!seg.isActive() || !seg.isSelected())) continue; if (i != firstSel && (!seg.isActive() || !seg.isSelected())) continue;
if (effectSpeed != mainsegPrev.speed) {seg.speed = effectSpeed; stateChanged = true;} if (effectSpeed != selsegPrev.speed) {seg.speed = effectSpeed; stateChanged = true;}
if (effectIntensity != mainsegPrev.intensity) {seg.intensity = effectIntensity; stateChanged = true;} if (effectIntensity != selsegPrev.intensity) {seg.intensity = effectIntensity; stateChanged = true;}
if (effectPalette != mainsegPrev.palette) {seg.palette = effectPalette; stateChanged = true;} if (effectPalette != selsegPrev.palette) {seg.palette = effectPalette; stateChanged = true;}
if (effectCurrent != mainsegPrev.mode) {strip.setMode(i, effectCurrent); stateChanged = true;} if (effectCurrent != selsegPrev.mode) {strip.setMode(i, effectCurrent); stateChanged = true;}
uint32_t col0 = RGBW32( col[0], col[1], col[2], col[3]); uint32_t col0 = RGBW32( col[0], col[1], col[2], col[3]);
uint32_t col1 = RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]); uint32_t col1 = RGBW32(colSec[0], colSec[1], colSec[2], colSec[3]);
if (col0 != mainsegPrev.colors[0]) {seg.setColor(0, col0, i); stateChanged = true;} if (col0 != selsegPrev.colors[0]) {seg.setColor(0, col0, i); stateChanged = true;}
if (col1 != mainsegPrev.colors[1]) {seg.setColor(1, col1, i); stateChanged = true;} if (col1 != selsegPrev.colors[1]) {seg.setColor(1, col1, i); stateChanged = true;}
} }
} }
@ -92,7 +94,7 @@ void applyFinalBri() {
void stateUpdated(byte callMode) { void stateUpdated(byte callMode) {
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification) //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa 11: ws send only 12: button preset // 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa 11: ws send only 12: button preset
setValuesFromMainSeg(); setValuesFromFirstSelectedSeg();
if (bri != briOld || stateChanged) { if (bri != briOld || stateChanged) {
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0; if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
@ -231,7 +233,7 @@ void handleNightlight()
colNlT[1] = effectSpeed; colNlT[1] = effectSpeed;
colNlT[2] = effectPalette; colNlT[2] = effectPalette;
strip.setMode(strip.getMainSegmentId(), FX_MODE_STATIC); //make sure seg runtime is reset if left in sunrise mode strip.setMode(strip.getFirstSelectedSegId(), FX_MODE_STATIC); // make sure seg runtime is reset if it was in sunrise mode
effectCurrent = FX_MODE_SUNRISE; effectCurrent = FX_MODE_SUNRISE;
effectSpeed = nightlightDelayMins; effectSpeed = nightlightDelayMins;
effectPalette = 0; effectPalette = 0;

View File

@ -542,13 +542,12 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
DEBUG_PRINTLN(req); DEBUG_PRINTLN(req);
//segment select (sets main segment) //segment select (sets main segment)
byte prevMain = strip.getMainSegmentId();
pos = req.indexOf(F("SM=")); pos = req.indexOf(F("SM="));
if (pos > 0) { if (pos > 0) {
strip.setMainSegmentId(getNumVal(&req, pos)); strip.setMainSegmentId(getNumVal(&req, pos));
} }
byte selectedSeg = strip.getMainSegmentId();
if (selectedSeg != prevMain) setValuesFromMainSeg(); byte selectedSeg = strip.getFirstSelectedSegId();
bool singleSegment = false; bool singleSegment = false;
@ -569,7 +568,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
selseg.setOption(SEG_OPTION_SELECTED, t); selseg.setOption(SEG_OPTION_SELECTED, t);
} }
// temporary values, write directly to segments, globals are updated by setValuesFromMainSeg() // temporary values, write directly to segments, globals are updated by setValuesFromFirstSelectedSeg()
uint32_t col0 = selseg.colors[0]; uint32_t col0 = selseg.colors[0];
uint32_t col1 = selseg.colors[1]; uint32_t col1 = selseg.colors[1];
byte colIn[4] = {R(col0), G(col0), B(col0), W(col0)}; byte colIn[4] = {R(col0), G(col0), B(col0), W(col0)};
@ -777,7 +776,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
if (intensityChanged) seg.intensity = intensityIn; if (intensityChanged) seg.intensity = intensityIn;
if (paletteChanged) seg.palette = paletteIn; if (paletteChanged) seg.palette = paletteIn;
} }
setValuesFromMainSeg(); // will fill col[] and cloSec[] as well as effectCurrent, ... setValuesFromFirstSelectedSeg(); // will fill col[] and cloSec[] as well as effectCurrent, ...
//set advanced overlay //set advanced overlay
pos = req.indexOf(F("OL=")); pos = req.indexOf(F("OL="));
@ -907,14 +906,15 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
} }
// you can add more if you need // you can add more if you need
if (!apply) return true; // when called by JSON API, do not call stateUpdated() here // global col[], effectCurrent, ... are updated in stateChanged()
if (!apply) return true; // when called by JSON API, do not call colorUpdated() here
//internal call, does not send XML response
pos = req.indexOf(F("IN"));
if (pos < 1) XML_response(request);
pos = req.indexOf(F("&NN")); //do not send UDP notifications this time pos = req.indexOf(F("&NN")); //do not send UDP notifications this time
stateUpdated((pos > 0) ? CALL_MODE_NO_NOTIFY : CALL_MODE_DIRECT_CHANGE); stateUpdated((pos > 0) ? CALL_MODE_NO_NOTIFY : CALL_MODE_DIRECT_CHANGE);
// internal call, does not send XML response
pos = req.indexOf(F("IN"));
if (pos < 1) XML_response(request);
return true; return true;
} }

View File

@ -292,28 +292,19 @@ void handleNotifications()
//apply colors from notification to main segment, only if not syncing full segments //apply colors from notification to main segment, only if not syncing full segments
if ((receiveNotificationColor || !someSel) && (version < 11 || !receiveSegmentOptions)) { if ((receiveNotificationColor || !someSel) && (version < 11 || !receiveSegmentOptions)) {
col[0] = udpIn[3]; // primary color, only apply white if intented (version > 0)
col[1] = udpIn[4]; strip.setColor(0, RGBW32(udpIn[3], udpIn[4], udpIn[5], (version > 0) ? udpIn[10] : 0));
col[2] = udpIn[5];
if (version > 0) //sending module's white val is intended
{
col[3] = udpIn[10];
if (version > 1) { if (version > 1) {
colSec[0] = udpIn[12]; strip.setColor(1, RGBW32(udpIn[12], udpIn[13], udpIn[14], udpIn[15])); // secondary color
colSec[1] = udpIn[13];
colSec[2] = udpIn[14];
colSec[3] = udpIn[15];
} }
if (version > 6) { if (version > 6) {
strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); //tertiary color strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); // tertiary color
if (version > 9 && version < 200 && udpIn[37] < 255) { //valid CCT/Kelvin value if (version > 9 && version < 200 && udpIn[37] < 255) { // valid CCT/Kelvin value
uint8_t cct = udpIn[38]; uint8_t cct = udpIn[38];
if (udpIn[37] > 0) { //Kelvin if (udpIn[37] > 0) { //Kelvin
cct = (((udpIn[37] << 8) + udpIn[38]) - 1900) >> 5; cct = (((udpIn[37] << 8) + udpIn[38]) - 1900) >> 5;
} }
uint8_t segid = strip.getMainSegmentId(); strip.setCCT(cct);
strip.getSegment(segid).setCCT(cct, segid);
}
} }
} }
} }
@ -362,11 +353,17 @@ void handleNotifications()
stateChanged = true; stateChanged = true;
} }
if (applyEffects && (version < 11 || !receiveSegmentOptions)) { //simple effect sync, applies to all selected // simple effect sync, applies to all selected segments
if (udpIn[8] < strip.getModeCount()) effectCurrent = udpIn[8]; if (applyEffects && (version < 11 || !receiveSegmentOptions)) {
effectSpeed = udpIn[9]; for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
if (version > 2) effectIntensity = udpIn[16]; WS2812FX::Segment& seg = strip.getSegment(i);
if (version > 4 && udpIn[19] < strip.getPaletteCount()) effectPalette = udpIn[19]; if (!seg.isActive() || !seg.isSelected()) continue;
if (udpIn[8] < strip.getModeCount()) strip.setMode(i, udpIn[8]);
seg.speed = udpIn[9];
if (version > 2) seg.intensity = udpIn[16];
if (version > 4 && udpIn[19] < strip.getPaletteCount()) seg.palette = udpIn[19];
}
stateChanged = true;
} }
if (applyEffects && version > 5) { if (applyEffects && version > 5) {
@ -411,7 +408,7 @@ void handleNotifications()
if (nightlightActive) nightlightDelayMins = udpIn[7]; if (nightlightActive) nightlightDelayMins = udpIn[7];
if (receiveNotificationBrightness || !someSel) bri = udpIn[2]; if (receiveNotificationBrightness || !someSel) bri = udpIn[2];
colorUpdated(CALL_MODE_NOTIFICATION); stateUpdated(CALL_MODE_NOTIFICATION);
return; return;
} }

View File

@ -435,11 +435,7 @@ void deEEP() {
strip.getSegment(j).setOption(SEG_OPTION_ON, 1); strip.getSegment(j).setOption(SEG_OPTION_ON, 1);
} }
} }
setValuesFromMainSeg();
serializeState(pObj, true, false, true); serializeState(pObj, true, false, true);
strip.resetSegments();
setValuesFromMainSeg();
} }
} }

View File

@ -238,9 +238,9 @@ void initServer()
server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){ server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){
if (Update.hasError()) if (Update.hasError())
{ {
serveMessage(request, 500, F("Failed updating firmware!"), F("Please check your file and retry!"), 254); return; serveMessage(request, 500, F("Update failed!"), F("Please check your file and retry!"), 254); return;
} }
serveMessage(request, 200, F("Successfully updated firmware!"), F("Rebooting..."), 131); serveMessage(request, 200, F("Update successful!"), F("Rebooting..."), 131);
doReboot = true; doReboot = true;
},[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){ },[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
if(!index){ if(!index){
@ -262,7 +262,7 @@ void initServer()
#else #else
server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){ server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 501, "Not implemented", F("OTA updates are disabled in this build."), 254); serveMessage(request, 501, "Not implemented", F("OTA updating is disabled in this build."), 254);
}); });
#endif #endif
} else } else

View File

@ -67,7 +67,7 @@ void XML_response(AsyncWebServerRequest *request, char* dest)
oappend(SET_F(" (live)")); oappend(SET_F(" (live)"));
} }
oappend(SET_F("</ds><ss>")); oappend(SET_F("</ds><ss>"));
oappendi(strip.getMainSegmentId()); oappendi(strip.getFirstSelectedSegId());
oappend(SET_F("</ss></vs>")); oappend(SET_F("</ss></vs>"));
if (request != nullptr) request->send(200, "text/xml", obuf); if (request != nullptr) request->send(200, "text/xml", obuf);
} }