From f632ef0de813e1646aa2dae1c5f5cdd9d6c11766 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Mon, 7 Jun 2021 21:07:15 +0200 Subject: [PATCH] Default dur from presetCycleTime. --- wled00/playlist.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 31051fff5..190e2fdc0 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -35,6 +35,7 @@ void shufflePlaylist() { DEBUG_PRINTLN(F("Playlist shuffle.")); } + void unloadPlaylist() { if (playlistEntries != nullptr) { delete[] playlistEntries; @@ -45,6 +46,7 @@ void unloadPlaylist() { DEBUG_PRINTLN(F("Playlist unloaded.")); } + void loadPlaylist(JsonObject playlistObj) { unloadPlaylist(); @@ -52,6 +54,7 @@ void loadPlaylist(JsonObject playlistObj) { playlistLen = presets.size(); if (playlistLen == 0) return; if (playlistLen > 100) playlistLen = 100; + playlistEntries = new PlaylistEntry[playlistLen]; if (playlistEntries == nullptr) return; @@ -70,7 +73,7 @@ void loadPlaylist(JsonObject playlistObj) { } else { for (int dur : durations) { if (it >= playlistLen) break; - playlistEntries[it].dur = dur; + playlistEntries[it].dur = (dur > 0) ? dur : presetCycleTime; it++; } } @@ -117,16 +120,13 @@ void handlePlaylist() { // playlist roll-over if (!playlistIndex) { // playlistRepeat < 0 => endless loop - if (playlistRepeat > 0) playlistRepeat--; // decrease repeat count on each index reset if not an endless playlist - if (playlistRepeat < -1) { // playlistRepeat < -1 => with shuffling presets - shufflePlaylist(); // shuffle playlist and start over - } + if (playlistRepeat > 0) playlistRepeat--; // decrease repeat count on each index reset if not an endless playlist + if (playlistRepeat < -1) shufflePlaylist(); // shuffle playlist and start over } jsonTransitionOnce = true; transitionDelayTemp = playlistEntries[playlistIndex].tr * 100; playlistEntryDur = playlistEntries[playlistIndex].dur; - if (playlistEntryDur == 0) playlistEntryDur = 10; applyPreset(playlistEntries[playlistIndex].preset); } }