diff --git a/CHANGELOG.md b/CHANGELOG.md index 148c9572..98b86d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ### Builds after release 0.12.0 +#### Build 2107041 + +- Restored support for "PL=~" mistakenly removed in 2106300 +- JSON IR improvements + #### Build 2107040 - Playlist entries are now more compact diff --git a/wled00/ir.cpp b/wled00/ir.cpp index ac921fb4..a38f7b01 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -580,13 +580,13 @@ void decodeIRJson(uint32_t code) { if (cmdStr.startsWith("!")) { // call limited set of C functions - if (cmdStr == "!incBrightness") { + if (cmdStr.startsWith(F("!incBri"))) { lastValidCode = code; incBrightness(); - } else if (cmdStr == "!decBrightness") { + } else if (cmdStr.startsWith(F("!decBri"))) { lastValidCode = code; decBrightness(); - } else if (cmdStr == "!presetFallback") { + } else if (cmdStr.startsWith(F("!presetF"))) { //!presetFallback uint8_t p1 = fdo["PL"] ? fdo["PL"] : 1; uint8_t p2 = fdo["FX"] ? fdo["FX"] : random8(100); uint8_t p3 = fdo["FP"] ? fdo["FP"] : 0; @@ -598,7 +598,8 @@ void decodeIRJson(uint32_t code) { // repeatable action lastValidCode = code; - } if (effectCurrent == 0 && cmdStr.indexOf("FP=") > -1) { + } + if (effectCurrent == 0 && cmdStr.indexOf("FP=") > -1) { // setting palette but it wont show because effect is solid effectCurrent = FX_MODE_GRADIENT; } @@ -609,7 +610,10 @@ void decodeIRJson(uint32_t code) } } else if (!jsonCmdObj.isNull()) { // command is JSON object + //allow applyPreset() to reuse JSON buffer, or it would alloc. a second buffer and run out of mem. + fileDoc = &irDoc; deserializeState(jsonCmdObj); + fileDoc = nullptr; } } } diff --git a/wled00/set.cpp b/wled00/set.cpp index fa4b8db5..b8417509 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -614,9 +614,16 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) pos = req.indexOf(F("PS=")); //saves current in preset if (pos > 0) savePreset(getNumVal(&req, pos)); + pos = req.indexOf(F("P1=")); //sets first preset for cycle + if (pos > 0) presetCycleMin = getNumVal(&req, pos); + + pos = req.indexOf(F("P2=")); //sets last preset for cycle + if (pos > 0) presetCycleMax = getNumVal(&req, pos); + //apply preset - pos = req.indexOf(F("PL=")); - if (pos > 0) applyPreset(getNumVal(&req, pos)); + if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) { + applyPreset(presetCycCurr); + } //set brightness updateVal(&req, "&A=", &bri); diff --git a/wled00/wled.h b/wled00/wled.h index 2cbeddab..a025ae46 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2107040 +#define VERSION 2107041 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -504,6 +504,9 @@ WLED_GLOBAL bool blynkEnabled _INIT(false); //playlists WLED_GLOBAL unsigned long presetCycledTime _INIT(0); WLED_GLOBAL int16_t currentPlaylist _INIT(0); +//still used for "PL=~" HTTP API command +WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5); +WLED_GLOBAL byte presetCycCurr _INIT(presetCycleMin); // realtime WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE);