Unloading playlist on effect change.
This commit is contained in:
parent
f632ef0de8
commit
024ec86dc5
@ -100,8 +100,8 @@ void handleIR();
|
||||
#include "src/dependencies/json/AsyncJson-v6.h"
|
||||
#include "FX.h"
|
||||
|
||||
void deserializeSegment(JsonObject elem, byte it);
|
||||
bool deserializeState(JsonObject root);
|
||||
void deserializeSegment(JsonObject elem, byte it, bool fromPlaylist = false);
|
||||
bool deserializeState(JsonObject root, bool fromPlaylist = false);
|
||||
void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset = false, bool segmentBounds = true, uint8_t versionAPI = 1);
|
||||
void serializeState(JsonObject root, bool forPreset = false, bool includeBri = true, bool segmentBounds = true);
|
||||
void serializeInfo(JsonObject root);
|
||||
@ -160,7 +160,7 @@ void loadPlaylist(JsonObject playlistObject);
|
||||
void handlePlaylist();
|
||||
|
||||
//presets.cpp
|
||||
bool applyPreset(byte index);
|
||||
bool applyPreset(byte index, bool fromPlaylist = false);
|
||||
void savePreset(byte index, bool persist = true, const char* pname = nullptr, JsonObject saveobj = JsonObject());
|
||||
void deletePreset(byte index);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* JSON API (De)serialization
|
||||
*/
|
||||
|
||||
void deserializeSegment(JsonObject elem, byte it)
|
||||
void deserializeSegment(JsonObject elem, byte it, bool fromPlaylist)
|
||||
{
|
||||
byte id = elem["id"] | it;
|
||||
if (id < strip.getMaxSegments())
|
||||
@ -127,6 +127,8 @@ void deserializeSegment(JsonObject elem, byte it)
|
||||
|
||||
//temporary, strip object gets updated via colorUpdated()
|
||||
if (id == strip.getMainSegmentId()) {
|
||||
// it may be a good idea to also stop playlist if effect has changed
|
||||
if (!fromPlaylist && !elem["fx"].isNull()) unloadPlaylist();
|
||||
effectCurrent = elem["fx"] | effectCurrent;
|
||||
effectSpeed = elem[F("sx")] | effectSpeed;
|
||||
effectIntensity = elem[F("ix")] | effectIntensity;
|
||||
@ -188,7 +190,7 @@ void deserializeSegment(JsonObject elem, byte it)
|
||||
}
|
||||
}
|
||||
|
||||
bool deserializeState(JsonObject root)
|
||||
bool deserializeState(JsonObject root, bool fromPlaylist)
|
||||
{
|
||||
strip.applyToAllSelected = false;
|
||||
bool stateResponse = root[F("v")] | false;
|
||||
@ -284,20 +286,20 @@ bool deserializeState(JsonObject root)
|
||||
{
|
||||
if (lowestActive == 99) lowestActive = s;
|
||||
if (sg.isSelected()) {
|
||||
deserializeSegment(segVar, s);
|
||||
deserializeSegment(segVar, s, fromPlaylist);
|
||||
didSet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!didSet && lowestActive < strip.getMaxSegments()) deserializeSegment(segVar, lowestActive);
|
||||
if (!didSet && lowestActive < strip.getMaxSegments()) deserializeSegment(segVar, lowestActive, fromPlaylist);
|
||||
} else { //set only the segment with the specified ID
|
||||
deserializeSegment(segVar, id);
|
||||
deserializeSegment(segVar, id, fromPlaylist);
|
||||
}
|
||||
} else {
|
||||
JsonArray segs = segVar.as<JsonArray>();
|
||||
for (JsonObject elem : segs)
|
||||
{
|
||||
deserializeSegment(elem, it);
|
||||
deserializeSegment(elem, it, fromPlaylist);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,6 @@ void handlePlaylist() {
|
||||
jsonTransitionOnce = true;
|
||||
transitionDelayTemp = playlistEntries[playlistIndex].tr * 100;
|
||||
playlistEntryDur = playlistEntries[playlistIndex].dur;
|
||||
applyPreset(playlistEntries[playlistIndex].preset);
|
||||
applyPreset(playlistEntries[playlistIndex].preset, true);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Methods to handle saving and loading presets to/from the filesystem
|
||||
*/
|
||||
|
||||
bool applyPreset(byte index)
|
||||
bool applyPreset(byte index, bool fromPlaylist)
|
||||
{
|
||||
if (index == 0) return false;
|
||||
if (fileDoc) { // from POST "/json" handler (wled_server.cpp)
|
||||
@ -14,7 +14,7 @@ bool applyPreset(byte index)
|
||||
#ifdef WLED_DEBUG_FS
|
||||
serializeJson(*fileDoc, Serial);
|
||||
#endif
|
||||
deserializeState(fdo);
|
||||
deserializeState(fdo, fromPlaylist);
|
||||
} else {
|
||||
DEBUGFS_PRINTLN(F("Make read buf"));
|
||||
DynamicJsonDocument fDoc(JSON_BUFFER_SIZE);
|
||||
@ -24,7 +24,7 @@ bool applyPreset(byte index)
|
||||
#ifdef WLED_DEBUG_FS
|
||||
serializeJson(fDoc, Serial);
|
||||
#endif
|
||||
deserializeState(fdo);
|
||||
deserializeState(fdo, fromPlaylist);
|
||||
}
|
||||
|
||||
if (!errorFlag) {
|
||||
|
Loading…
Reference in New Issue
Block a user