From 90808ac67ee08a67ff1d92b21079a4b6623a97c4 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 28 Feb 2021 15:34:18 +0100 Subject: [PATCH] Power off playlist unload. --- wled00/fcn_declare.h | 1 + wled00/led.cpp | 1 + wled00/playlist.cpp | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index c789211b4..4d0c58069 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -166,6 +166,7 @@ class PinManagerClass { }; //playlist.cpp +void unloadPlaylist(); void loadPlaylist(JsonObject playlistObject); void handlePlaylist(); diff --git a/wled00/led.cpp b/wled00/led.cpp index 32e38f7d7..9f887667e 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -30,6 +30,7 @@ void toggleOnOff() { briLast = bri; bri = 0; + unloadPlaylist(); } } diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 911e26929..b294fdef7 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -74,9 +74,19 @@ void serializePlaylist() { } */ +void unloadPlaylist() { + if (playlistEntries != nullptr) { + delete[] playlistEntries; + playlistEntries = nullptr; + } + currentPlaylist = playlistIndex = -1; + playlistLen = playlistEntryDur = 0; +} + void loadPlaylist(JsonObject playlistObj) { - if (playlistEntries != nullptr) {delete[] playlistEntries; playlistEntries = nullptr;} - currentPlaylist = playlistIndex = -1; playlistEntryDur = 0; + + unloadPlaylist(); + JsonArray presets = playlistObj["ps"]; playlistLen = presets.size(); if (playlistLen == 0) return;