diff --git a/CHANGELOG.md b/CHANGELOG.md index c70c8600..7a0318bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ### Development versions after 0.11.1 release +#### Build 2101040 + +- Replaced Red & Blue effect with Aurora effect (PR #1589) +- Fixed HTTP changing segments uncommanded (#1618) +- Updated copyright year and contributor page link + #### Build 2012311 - Fixed Countdown mode diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 4d66a67a..96044512 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -394,7 +394,10 @@ void WS2812FX::setColor(uint8_t slot, uint32_t c) { if (applyToAllSelected) { for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { - if (_segments[i].isSelected()) _segments[i].colors[slot] = c; + if (_segments[i].isSelected()) { + _segments[i].colors[slot] = c; + applied = true; + } } } diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 0996de07..625d9d10 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -33,6 +33,11 @@ void colorFromUint24(uint32_t in, bool secondary) } } +//store color components in uint32_t +uint32_t colorFromRgbw(byte* rgbw) { + return (rgbw[0] << 16) + (rgbw[1] << 8) + rgbw[2] + (rgbw[3] << 24); +} + //relatively change white brightness, minumum A=5 void relativeChangeWhite(int8_t amount, byte lowerBoundary) { diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm index f4761db1..f9d1a3a5 100644 --- a/wled00/data/settings_sec.htm +++ b/wled00/data/settings_sec.htm @@ -46,9 +46,9 @@ Enable ArduinoOTA:

About

WLED version ##VERSION##

- Contributors, dependencies and special thanks
+ Contributors, dependencies and special thanks
A huge thank you to everyone who helped me create WLED!

- (c) 2016-2020 Christian Schwinne
+ (c) 2016-2021 Christian Schwinne
Licensed under the MIT license

Server message: Response error!
diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index a1c60eee..4e27f129 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -34,6 +34,7 @@ void serializeConfigSec(); //colors.cpp void colorFromUint32(uint32_t in, bool secondary = false); void colorFromUint24(uint32_t in, bool secondary = false); +uint32_t colorFromRgbw(byte* rgbw); 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); diff --git a/wled00/set.cpp b/wled00/set.cpp index e7864529..c66abdb3 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -381,7 +381,14 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) DEBUG_PRINT(F("API req: ")); DEBUG_PRINTLN(req); - strip.applyToAllSelected = true; + strip.applyToAllSelected = false; + //snapshot to check if request changed values later, temporary. + byte prevCol[4] = {col[0], col[1], col[2], col[3]}; + byte prevColSec[4] = {colSec[0], colSec[1], colSec[2], colSec[3]}; + byte prevEffect = effectCurrent; + byte prevSpeed = effectSpeed; + byte prevIntensity = effectIntensity; + byte prevPalette = effectPalette; //segment select (sets main segment) byte prevMain = strip.getMainSegmentId(); @@ -389,16 +396,16 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) if (pos > 0) { strip.mainSegment = getNumVal(&req, pos); } - byte main = strip.getMainSegmentId(); - if (main != prevMain) setValuesFromMainSeg(); + byte selectedSeg = strip.getMainSegmentId(); + if (selectedSeg != prevMain) setValuesFromMainSeg(); pos = req.indexOf(F("SS=")); if (pos > 0) { byte t = getNumVal(&req, pos); - if (t < strip.getMaxSegments()) main = t; + if (t < strip.getMaxSegments()) selectedSeg = t; } - WS2812FX::Segment& mainseg = strip.getSegment(main); + WS2812FX::Segment& mainseg = strip.getSegment(selectedSeg); pos = req.indexOf(F("SV=")); //segment selected if (pos > 0) { byte t = getNumVal(&req, pos); @@ -432,9 +439,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) if (pos > 0) { spcI = getNumVal(&req, pos); } - strip.setSegment(main, startI, stopI, grpI, spcI); - - main = strip.getMainSegmentId(); + strip.setSegment(selectedSeg, startI, stopI, grpI, spcI); //set presets pos = req.indexOf(F("P1=")); //sets first preset for cycle @@ -532,7 +537,12 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) if (pos > 0) { byte t[4]; colorFromDecOrHexString(t, (char*)req.substring(pos + 3).c_str()); - strip.setColor(2, t[0], t[1], t[2], t[3]); + if (selectedSeg != strip.getMainSegmentId()) { + strip.applyToAllSelected = true; + strip.setColor(2, t[0], t[1], t[2], t[3]); + } else { + strip.getSegment(selectedSeg).colors[2] = ((t[0] << 16) + (t[1] << 8) + t[2] + (t[3] << 24)); + } } //set to random hue SR=0->1st SR=1->2nd @@ -647,19 +657,19 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) //Segment reverse pos = req.indexOf(F("RV=")); - if (pos > 0) strip.getSegment(main).setOption(SEG_OPTION_REVERSED, req.charAt(pos+3) != '0'); + if (pos > 0) strip.getSegment(selectedSeg).setOption(SEG_OPTION_REVERSED, req.charAt(pos+3) != '0'); //Segment reverse pos = req.indexOf(F("MI=")); - if (pos > 0) strip.getSegment(main).setOption(SEG_OPTION_MIRROR, req.charAt(pos+3) != '0'); + if (pos > 0) strip.getSegment(selectedSeg).setOption(SEG_OPTION_MIRROR, req.charAt(pos+3) != '0'); //Segment brightness/opacity pos = req.indexOf(F("SB=")); if (pos > 0) { byte segbri = getNumVal(&req, pos); - strip.getSegment(main).setOption(SEG_OPTION_ON, segbri); + strip.getSegment(selectedSeg).setOption(SEG_OPTION_ON, segbri); if (segbri) { - strip.getSegment(main).opacity = segbri; + strip.getSegment(selectedSeg).opacity = segbri; } } @@ -716,12 +726,44 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) } //you can add more if you need + //apply to all selected manually to prevent #1618. Temporary + bool col0Changed = false, col1Changed = false; + for (uint8_t i = 0; i < 4; i++) { + if (col[i] != prevCol[i]) col0Changed = true; + if (colSec[i] != prevColSec[i]) col1Changed = true; + } + for (uint8_t i = 0; i < strip.getMaxSegments(); i++) + { + WS2812FX::Segment& seg = strip.getSegment(i); + if (!seg.isSelected()) continue; + if (effectCurrent != prevEffect) seg.mode = effectCurrent; + if (effectSpeed != prevSpeed) seg.speed = effectSpeed; + if (effectIntensity != prevIntensity) seg.intensity = effectIntensity; + if (effectPalette != prevPalette) seg.palette = effectPalette; + } + + if (col0Changed) { + if (selectedSeg == strip.getMainSegmentId()) { + strip.applyToAllSelected = true; + strip.setColor(0, colorFromRgbw(col)); + } + } + if (col1Changed) { + if (selectedSeg == strip.getMainSegmentId()) { + strip.applyToAllSelected = true; + strip.setColor(1, colorFromRgbw(colSec)); + } + } + //end of temporary fix code + 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); + strip.applyToAllSelected = false; + pos = req.indexOf(F("&NN")); //do not send UDP notifications this time colorUpdated((pos > 0) ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE); diff --git a/wled00/wled.h b/wled00/wled.h index ad4e701e..81155ab9 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2012311 +#define VERSION 2101040 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG