From ecfdc6f0a804e00c3362bfb02968b99ed00d64a3 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Fri, 22 Mar 2024 20:49:13 +0100 Subject: [PATCH] Bugfixes: - #3843 - #3844 - network scan on new install - misc optimization --- wled00/cfg.cpp | 4 ++-- wled00/const.h | 1 + wled00/data/index.js | 2 +- wled00/data/settings_wifi.htm | 2 +- wled00/fcn_declare.h | 1 + wled00/playlist.cpp | 11 +++++++---- wled00/presets.cpp | 9 +++++++++ wled00/wled.h | 2 +- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index e51b666e48..6ccf8aa445 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -632,12 +632,12 @@ static const char s_cfg_json[] PROGMEM = "/cfg.json"; void deserializeConfigFromFS() { bool success = deserializeConfigSec(); + #ifdef WLED_ADD_EEPROM_SUPPORT if (!success) { //if file does not exist, try reading from EEPROM - #ifdef WLED_ADD_EEPROM_SUPPORT deEEPSettings(); return; - #endif } + #endif if (!requestJSONBufferLock(1)) return; diff --git a/wled00/const.h b/wled00/const.h index 540d0946bf..73873d041f 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -375,6 +375,7 @@ //Playlist option byte #define PL_OPTION_SHUFFLE 0x01 +#define PL_OPTION_RESTORE 0x02 // Segment capability byte #define SEG_CAPABILITY_RGB 0x01 diff --git a/wled00/data/index.js b/wled00/data/index.js index 36c3eb1b98..4ad2044ad8 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -1984,7 +1984,7 @@ function makeP(i,pl)
End preset:
diff --git a/wled00/data/settings_wifi.htm b/wled00/data/settings_wifi.htm index 76e733671c..3577e80d2c 100644 --- a/wled00/data/settings_wifi.htm +++ b/wled00/data/settings_wifi.htm @@ -84,7 +84,7 @@ option.textContent = "Other network..."; select.appendChild(option); - if (input.value === "" || found) input.replaceWith(select); + if (input.value === "" || input.value === "Your_Network" || found) input.replaceWith(select); else select.remove(); } diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 20ac21129d..f1b013e99b 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -233,6 +233,7 @@ const char *getPresetsFileName(bool persistent = true); void initPresetsFile(); void handlePresets(); bool applyPreset(byte index, byte callMode = CALL_MODE_DIRECT_CHANGE); +bool applyPresetFromPlaylist(byte index); void applyPresetWithFallback(uint8_t presetID, uint8_t callMode, uint8_t effectID = 0, uint8_t paletteID = 0); inline bool applyTemporaryPreset() {return applyPreset(255);}; void savePreset(byte index, const char* pname = nullptr, JsonObject saveobj = JsonObject()); diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index bcbcb4516f..882ccb0e0f 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -109,7 +109,10 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) { if (playlistRepeat > 0) playlistRepeat++; //add one extra repetition immediately since it will be deducted on first start playlistEndPreset = playlistObj["end"] | 0; // if end preset is 255 restore original preset (if any running) upon playlist end - if (playlistEndPreset == 255 && currentPreset > 0) playlistEndPreset = currentPreset; + if (playlistEndPreset == 255 && currentPreset > 0) { + playlistEndPreset = currentPreset; + playlistOptions |= PL_OPTION_RESTORE; // for async save operation + } if (playlistEndPreset > 250) playlistEndPreset = 0; shuffle = shuffle || playlistObj["r"]; if (shuffle) playlistOptions |= PL_OPTION_SHUFFLE; @@ -135,7 +138,7 @@ void handlePlaylist() { if (!playlistIndex) { if (playlistRepeat == 1) { //stop if all repetitions are done unloadPlaylist(); - if (playlistEndPreset) applyPreset(playlistEndPreset); + if (playlistEndPreset) applyPresetFromPlaylist(playlistEndPreset); return; } if (playlistRepeat > 1) playlistRepeat--; // decrease repeat count on each index reset if not an endless playlist @@ -146,7 +149,7 @@ void handlePlaylist() { jsonTransitionOnce = true; strip.setTransition(fadeTransition ? playlistEntries[playlistIndex].tr * 100 : 0); playlistEntryDur = playlistEntries[playlistIndex].dur; - applyPreset(playlistEntries[playlistIndex].preset); + applyPresetFromPlaylist(playlistEntries[playlistIndex].preset); } } @@ -157,7 +160,7 @@ void serializePlaylist(JsonObject sObj) { JsonArray dur = playlist.createNestedArray("dur"); JsonArray transition = playlist.createNestedArray(F("transition")); playlist[F("repeat")] = (playlistIndex < 0 && playlistRepeat > 0) ? playlistRepeat - 1 : playlistRepeat; // remove added repetition count (if not yet running) - playlist["end"] = playlistEndPreset; + playlist["end"] = playlistOptions & PL_OPTION_RESTORE ? 255 : playlistEndPreset; playlist["r"] = playlistOptions & PL_OPTION_SHUFFLE; for (int i=0; i