Fixed preset cycle not working from preset called by UI

This commit is contained in:
cschwinne 2021-11-22 21:41:04 +01:00
parent 31b7cdff9b
commit 80a657965e
4 changed files with 16 additions and 9 deletions

View File

@ -2,6 +2,11 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2111220
- Fixed preset cycle not working from preset called by UI
- Reintroduced permanent min. and max. cycle bounds
#### Build 2111190 #### Build 2111190
- Changed default ESP32 LED pin from 16 to 2 - Changed default ESP32 LED pin from 16 to 2

View File

@ -339,9 +339,11 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
deletePreset(ps); deletePreset(ps);
} }
if (getVal(root["ps"], &presetCycCurr, 1, 5)) { //load preset (clears state request!) ps = presetCycCurr;
if (getVal(root["ps"], &ps, presetCycMin, presetCycMax)) { //load preset (clears state request!)
if (!presetId) unloadPlaylist(); //stop playlist if preset changed manually if (!presetId) unloadPlaylist(); //stop playlist if preset changed manually
applyPreset(presetCycCurr, callMode); if (ps >= presetCycMin && ps <= presetCycMax) presetCycCurr = ps;
applyPreset(ps, callMode);
return stateResponse; return stateResponse;
} }

View File

@ -547,6 +547,7 @@ void parseNumber(const char* str, byte* val, byte minv, byte maxv)
const char* str2 = strchr(str,'~'); //min/max range (for preset cycle, e.g. "1~5~") const char* str2 = strchr(str,'~'); //min/max range (for preset cycle, e.g. "1~5~")
if (str2) { if (str2) {
byte p2 = atoi(str2+1); byte p2 = atoi(str2+1);
presetCycMin = p1; presetCycMax = p2;
while (isdigit((str2+1)[0])) str2++; while (isdigit((str2+1)[0])) str2++;
parseNumber(str2+1, val, p1, p2); parseNumber(str2+1, val, p1, p2);
} else { } else {
@ -655,17 +656,14 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
pos = req.indexOf(F("PS=")); //saves current in preset pos = req.indexOf(F("PS=")); //saves current in preset
if (pos > 0) savePreset(getNumVal(&req, pos)); if (pos > 0) savePreset(getNumVal(&req, pos));
byte presetCycleMin = 1;
byte presetCycleMax = 5;
pos = req.indexOf(F("P1=")); //sets first preset for cycle pos = req.indexOf(F("P1=")); //sets first preset for cycle
if (pos > 0) presetCycleMin = getNumVal(&req, pos); if (pos > 0) presetCycMin = getNumVal(&req, pos);
pos = req.indexOf(F("P2=")); //sets last preset for cycle pos = req.indexOf(F("P2=")); //sets last preset for cycle
if (pos > 0) presetCycleMax = getNumVal(&req, pos); if (pos > 0) presetCycMax = getNumVal(&req, pos);
//apply preset //apply preset
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) { if (updateVal(&req, "PL=", &presetCycCurr, presetCycMin, presetCycMax)) {
applyPreset(presetCycCurr); applyPreset(presetCycCurr);
} }

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2111190 #define VERSION 2111220
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG
@ -515,6 +515,8 @@ WLED_GLOBAL unsigned long presetCycledTime _INIT(0);
WLED_GLOBAL int16_t currentPlaylist _INIT(-1); WLED_GLOBAL int16_t currentPlaylist _INIT(-1);
//still used for "PL=~" HTTP API command //still used for "PL=~" HTTP API command
WLED_GLOBAL byte presetCycCurr _INIT(0); WLED_GLOBAL byte presetCycCurr _INIT(0);
WLED_GLOBAL byte presetCycMin _INIT(1);
WLED_GLOBAL byte presetCycMax _INIT(5);
// realtime // realtime
WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE); WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE);