From ca73a57de7952958f9396570cdb896e1fad1ca5b Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 29 Jan 2023 11:27:14 +0100 Subject: [PATCH] Bugfix. - reduce playlist repetition count on save #3058 --- wled00/playlist.cpp | 2 +- wled00/presets.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 01b570ab..98aab345 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -156,7 +156,7 @@ void serializePlaylist(JsonObject sObj) { JsonArray ps = playlist.createNestedArray("ps"); JsonArray dur = playlist.createNestedArray("dur"); JsonArray transition = playlist.createNestedArray(F("transition")); - playlist[F("repeat")] = playlistRepeat; + playlist[F("repeat")] = (playlistRepeat > 0) ? playlistRepeat - 1 : 0; // remove added repetition count playlist["end"] = playlistEndPreset; playlist["r"] = playlistOptions & PL_OPTION_SHUFFLE; for (int i=0; i 250 || !fileDoc) return; // cannot save API calls to temporary preset (255) sObj.remove("o"); @@ -220,11 +220,12 @@ void savePreset(byte index, const char* pname, JsonObject sObj) sObj.remove(F("psave")); if (sObj["n"].isNull()) sObj["n"] = saveName; initPresetsFile(); // just in case if someone deleted presets.json using /edit - writeObjectToFileUsingId(getFileName(index), index, fileDoc); + writeObjectToFileUsingId(getFileName(index<255), index, fileDoc); presetsModifiedTime = toki.second(); //unix time updateFSInfo(); } else { // store playlist + // WARNING: playlist will be loaded in json.cpp after this call and will have repeat counter increased by 1 includeBri = true; // !sObj["on"].isNull(); playlistSave = true; }