From b849ea8eaacdf1b24becc998f6bbbc06e052d71f Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 18 Mar 2024 20:01:32 +0100 Subject: [PATCH] Fix for #3827 --- wled00/button.cpp | 3 --- wled00/e131.cpp | 1 - wled00/json.cpp | 2 -- wled00/ntp.cpp | 3 --- wled00/presets.cpp | 1 + wled00/remote.cpp | 1 - wled00/set.cpp | 1 - 7 files changed, 1 insertion(+), 11 deletions(-) diff --git a/wled00/button.cpp b/wled00/button.cpp index 29cb0abebf..cf4599834d 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -21,7 +21,6 @@ void shortPressAction(uint8_t b) case 1: ++effectCurrent %= strip.getModeCount(); stateChanged = true; colorUpdated(CALL_MODE_BUTTON); break; } } else { - unloadPlaylist(); // applying a preset unloads the playlist applyPreset(macroButton[b], CALL_MODE_BUTTON_PRESET); } @@ -43,7 +42,6 @@ void longPressAction(uint8_t b) case 1: bri += 8; stateUpdated(CALL_MODE_BUTTON); buttonPressedTime[b] = millis(); break; // repeatable action } } else { - unloadPlaylist(); // applying a preset unloads the playlist applyPreset(macroLongPress[b], CALL_MODE_BUTTON_PRESET); } @@ -65,7 +63,6 @@ void doublePressAction(uint8_t b) case 1: ++effectPalette %= strip.getPaletteCount(); colorUpdated(CALL_MODE_BUTTON); break; } } else { - unloadPlaylist(); // applying a preset unloads the playlist applyPreset(macroDoublePress[b], CALL_MODE_BUTTON_PRESET); } diff --git a/wled00/e131.cpp b/wled00/e131.cpp index e54f60bf3c..ec2efb50e3 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -184,7 +184,6 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ // only apply preset if not in playlist, or playlist changed (currentPlaylist < 0 || dmxValPreset != currentPlaylist)) { presetCycCurr = dmxValPreset; - unloadPlaylist(); // applying a preset unloads the playlist applyPreset(dmxValPreset, CALL_MODE_NOTIFICATION); } diff --git a/wled00/json.cpp b/wled00/json.cpp index 389dc8ae56..84caedd221 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -442,13 +442,11 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) currentPreset = root[F("pd")] | currentPreset; if (root["win"].isNull()) presetCycCurr = currentPreset; // otherwise it was set in handleSet() [set.cpp] presetToRestore = currentPreset; // stateUpdated() will clear the preset, so we need to restore it after - //unloadPlaylist(); // applying a preset unloads the playlist, may be needed here too? } else if (!root["ps"].isNull()) { ps = presetCycCurr; if (root["win"].isNull() && getVal(root["ps"], &ps, 0, 0) && ps > 0 && ps < 251 && ps != currentPreset) { // b) preset ID only or preset that does not change state (use embedded cycling limits if they exist in getVal()) presetCycCurr = ps; - unloadPlaylist(); // applying a preset unloads the playlist applyPreset(ps, callMode); // async load from file system (only preset ID was specified) return stateResponse; } diff --git a/wled00/ntp.cpp b/wled00/ntp.cpp index 0b2cf36652..d473186edf 100644 --- a/wled00/ntp.cpp +++ b/wled00/ntp.cpp @@ -399,7 +399,6 @@ void checkTimers() && isTodayInDateRange(((timerMonth[i] >> 4) & 0x0F), timerDay[i], timerMonth[i] & 0x0F, timerDayEnd[i]) ) { - unloadPlaylist(); applyPreset(timerMacro[i]); } } @@ -413,7 +412,6 @@ void checkTimers() && (timerWeekday[8] & 0x01) //timer is enabled && ((timerWeekday[8] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week { - unloadPlaylist(); applyPreset(timerMacro[8]); DEBUG_PRINTF_P(PSTR("Sunrise macro %d triggered."),timerMacro[8]); } @@ -428,7 +426,6 @@ void checkTimers() && (timerWeekday[9] & 0x01) //timer is enabled && ((timerWeekday[9] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week { - unloadPlaylist(); applyPreset(timerMacro[9]); DEBUG_PRINTF_P(PSTR("Sunset macro %d triggered."),timerMacro[9]); } diff --git a/wled00/presets.cpp b/wled00/presets.cpp index 7fbe49eb80..6efe3bb31c 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -119,6 +119,7 @@ void initPresetsFile() bool applyPreset(byte index, byte callMode) { + unloadPlaylist(); // applying a preset unloads the playlist (#3827) DEBUG_PRINT(F("Request to apply preset: ")); DEBUG_PRINTLN(index); presetToApply = index; diff --git a/wled00/remote.cpp b/wled00/remote.cpp index 49fbc4b020..54cdf31f60 100644 --- a/wled00/remote.cpp +++ b/wled00/remote.cpp @@ -108,7 +108,6 @@ static void setOff() { void presetWithFallback(uint8_t presetID, uint8_t effectID, uint8_t paletteID) { resetNightMode(); - unloadPlaylist(); applyPresetWithFallback(presetID, CALL_MODE_BUTTON_PRESET, effectID, paletteID); } diff --git a/wled00/set.cpp b/wled00/set.cpp index 4e2e60b3da..6e7064bb30 100755 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -883,7 +883,6 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) //apply preset if (updateVal(req.c_str(), "PL=", &presetCycCurr, presetCycMin, presetCycMax)) { - unloadPlaylist(); applyPreset(presetCycCurr); }