From 131625bb538d8efd93ea4744bffa752ecadd581f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Mon, 7 Jun 2021 14:16:29 +0200 Subject: [PATCH] Endless playlist fix. --- wled00/playlist.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 5a3b0799..cf9df4bc 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -10,6 +10,7 @@ typedef struct PlaylistEntry { uint16_t tr; } ple; +bool playlistEndless = false; int8_t playlistRepeat = 1; byte playlistEndPreset = 0; byte *playlistEntries = nullptr; @@ -92,6 +93,9 @@ void loadPlaylist(JsonObject playlistObj) { playlistRepeat = playlistObj[F("repeat")] | 0; playlistEndPreset = playlistObj[F("end")] | 0; + playlistEndless = playlistRepeat < 1; + if (playlistEndless && playlistRepeat==0) playlistRepeat = 1; // it will never decrement + currentPlaylist = 0; //TODO here we need the preset ID where the playlist is saved } @@ -112,9 +116,8 @@ void handlePlaylist() { } // playlist roll-over if (!playlistIndex) { - if (playlistRepeat > 0) {// playlistRepeat < 0 => endless loop with shuffling presets - playlistRepeat--; // decrease repeat count on each index reset - } else { + if (!playlistEndless) playlistRepeat--; // decrease repeat count on each index reset if not an endless playlist + if (playlistRepeat < 0) {// playlistRepeat < 0 => endless loop with shuffling presets shufflePlaylist(); // shuffle playlist and start over } }