Updated based on more feedback

This commit is contained in:
Todd Meyer 2024-05-02 14:36:18 -07:00
parent db475b6998
commit 5e38039c4d
5 changed files with 8 additions and 13 deletions

View File

@ -226,7 +226,7 @@ void _overlayAnalogClock();
void shufflePlaylist(); void shufflePlaylist();
void unloadPlaylist(); void unloadPlaylist();
int16_t loadPlaylist(JsonObject playlistObject, byte presetId = 0); int16_t loadPlaylist(JsonObject playlistObject, byte presetId = 0);
void handlePlaylist(bool doAdvancePlaylist = false); void handlePlaylist();
void serializePlaylist(JsonObject obj); void serializePlaylist(JsonObject obj);
//presets.cpp //presets.cpp

View File

@ -486,9 +486,9 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
strip.loadCustomPalettes(); strip.loadCustomPalettes();
} }
} }
if (root.containsKey(F("np")) && root[F("np")].as<bool>()) { //skip to next preset in a playlist if (root.containsKey(F("np"))) {
doAdvancePlaylist = true; doAdvancePlaylist = root[F("np")].as<bool>(); //advances to next preset in playlist when true
} }
JsonObject wifi = root[F("wifi")]; JsonObject wifi = root[F("wifi")];

View File

@ -123,7 +123,7 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) {
} }
void handlePlaylist(bool doAdvancePlaylist) { void handlePlaylist() {
static unsigned long presetCycledTime = 0; static unsigned long presetCycledTime = 0;
if (currentPlaylist < 0 || playlistEntries == nullptr) return; if (currentPlaylist < 0 || playlistEntries == nullptr) return;
@ -149,6 +149,7 @@ if (millis() - presetCycledTime > (100 * playlistEntryDur) || doAdvancePlaylist)
strip.setTransition(fadeTransition ? playlistEntries[playlistIndex].tr * 100 : 0); strip.setTransition(fadeTransition ? playlistEntries[playlistIndex].tr * 100 : 0);
playlistEntryDur = playlistEntries[playlistIndex].dur; playlistEntryDur = playlistEntries[playlistIndex].dur;
applyPresetFromPlaylist(playlistEntries[playlistIndex].preset); applyPresetFromPlaylist(playlistEntries[playlistIndex].preset);
doAdvancePlaylist = false;
} }
} }

View File

@ -901,8 +901,8 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
applyPreset(presetCycCurr); applyPreset(presetCycCurr);
} }
pos = req.indexOf(F("NP")); //skips to next preset in a playlist pos = req.indexOf(F("NP")); //advances to next preset in a playlist
if (pos > 0) doAdvancePlaylist = true; if (pos > 0) doAdvancePlaylist = true;
//set brightness //set brightness
updateVal(req.c_str(), "&A=", &bri); updateVal(req.c_str(), "&A=", &bri);

View File

@ -209,12 +209,6 @@ void WLED::loop()
toki.resetTick(); toki.resetTick();
// Advance to next playlist preset if the flag is set to true
if (doAdvancePlaylist) {
handlePlaylist(true);
doAdvancePlaylist = false; // Reset flag to false
}
#if WLED_WATCHDOG_TIMEOUT > 0 #if WLED_WATCHDOG_TIMEOUT > 0
// we finished our mainloop, reset the watchdog timer // we finished our mainloop, reset the watchdog timer
static unsigned long lastWDTFeed = 0; static unsigned long lastWDTFeed = 0;