diff --git a/wled00/json.cpp b/wled00/json.cpp index a6e4af86f..79c448809 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -223,7 +223,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) if (root["on"].is() && root["on"].as()[0] == 't') toggleOnOff(); int tr = -1; - if (!presetId || currentPlaylist < 0) { //do not apply transition time from preset if playlist active, as it would override playlist transition times + if (!presetId || !currentPlaylist) { //do not apply transition time from preset if playlist active, as it would override playlist transition times tr = root[F("transition")] | -1; if (tr >= 0) { @@ -415,8 +415,8 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme if (!forPreset) { if (errorFlag) {root[F("error")] = errorFlag; errorFlag = ERR_NONE;} - root[F("ps")] = currentPreset; - root[F("pl")] = currentPlaylist; + root[F("ps")] = currentPreset>0 ? currentPreset : -1; + root[F("pl")] = currentPlaylist>0 ? currentPlaylist : -1; usermods.addToJsonState(root); diff --git a/wled00/led.cpp b/wled00/led.cpp index 0496a40e9..4f2190ce6 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -111,7 +111,7 @@ void colorUpdated(int callMode) { effectChanged = false; if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0; - currentPreset = -1; //something changed, so we are no longer in the preset + currentPreset = 0; //something changed, so we are no longer in the preset notify(callMode); diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 850b090fe..31bcede5d 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -47,7 +47,8 @@ void unloadPlaylist() { delete[] playlistEntries; playlistEntries = nullptr; } - currentPlaylist = playlistIndex = -1; + currentPlaylist = 0; + playlistIndex = -1; playlistLen = playlistEntryDur = playlistOptions = 0; DEBUG_PRINTLN(F("Playlist unloaded.")); } @@ -118,7 +119,8 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) { void handlePlaylist() { - if (currentPlaylist < 0 || playlistEntries == nullptr) return; + static unsigned long presetCycledTime = 0; + if (!currentPlaylist || playlistEntries == nullptr) return; if (millis() - presetCycledTime > (100*playlistEntryDur)) { presetCycledTime = millis(); diff --git a/wled00/set.cpp b/wled00/set.cpp index edab9fdec..5449c4126 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -650,6 +650,9 @@ 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)); + byte presetCycleMin = 1; + byte presetCycleMax = 5; + byte presetCycCurr; pos = req.indexOf(F("P1=")); //sets first preset for cycle if (pos > 0) presetCycleMin = getNumVal(&req, pos); diff --git a/wled00/wled.h b/wled00/wled.h index 3135e7695..0a0878457 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2110041 +#define VERSION 2110061 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -513,11 +513,7 @@ WLED_GLOBAL byte timerWeekday[] _INIT_N(({ 255, 255, 255, 255, 255, 255, 255, 25 WLED_GLOBAL bool blynkEnabled _INIT(false); //playlists -WLED_GLOBAL unsigned long presetCycledTime _INIT(0); -WLED_GLOBAL int16_t currentPlaylist _INIT(-1); -//still used for "PL=~" HTTP API command -WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5); -WLED_GLOBAL byte presetCycCurr _INIT(presetCycleMin); +WLED_GLOBAL byte currentPlaylist _INIT(0); // realtime WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE); @@ -569,7 +565,7 @@ WLED_GLOBAL JsonDocument* fileDoc; WLED_GLOBAL bool doCloseFile _INIT(false); // presets -WLED_GLOBAL int16_t currentPreset _INIT(-1); +WLED_GLOBAL byte currentPreset _INIT(0); WLED_GLOBAL byte errorFlag _INIT(0); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 7e51e0606..1b83a5faf 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -60,7 +60,7 @@ void XML_response(AsyncWebServerRequest *request, char* dest) oappend(SET_F("")); oappendi(colSec[3]); oappend(SET_F("")); - oappendi((currentPreset < 1) ? 0:currentPreset); + oappendi(currentPreset); oappend(SET_F("")); oappendi(currentPlaylist > 0); oappend(SET_F(""));