RAM optimizations:
- changed int16_t to byte for currentPreset and currentPlaylist - removed presetCycXxxxx variables
This commit is contained in:
parent
7b21c1bcbe
commit
9f230ae339
@ -223,7 +223,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
||||
if (root["on"].is<const char*>() && root["on"].as<const char*>()[0] == 't') toggleOnOff();
|
||||
|
||||
int tr = -1;
|
||||
if (!presetId || currentPlaylist < 0) { //do not apply transition time from preset if playlist active, as it would override playlist transition times
|
||||
if (!presetId || !currentPlaylist) { //do not apply transition time from preset if playlist active, as it would override playlist transition times
|
||||
tr = root[F("transition")] | -1;
|
||||
if (tr >= 0)
|
||||
{
|
||||
@ -415,8 +415,8 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
|
||||
if (!forPreset) {
|
||||
if (errorFlag) {root[F("error")] = errorFlag; errorFlag = ERR_NONE;}
|
||||
|
||||
root[F("ps")] = currentPreset;
|
||||
root[F("pl")] = currentPlaylist;
|
||||
root[F("ps")] = currentPreset>0 ? currentPreset : -1;
|
||||
root[F("pl")] = currentPlaylist>0 ? currentPlaylist : -1;
|
||||
|
||||
usermods.addToJsonState(root);
|
||||
|
||||
|
@ -111,7 +111,7 @@ void colorUpdated(int callMode)
|
||||
{
|
||||
effectChanged = false;
|
||||
if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0;
|
||||
currentPreset = -1; //something changed, so we are no longer in the preset
|
||||
currentPreset = 0; //something changed, so we are no longer in the preset
|
||||
|
||||
notify(callMode);
|
||||
|
||||
|
@ -47,7 +47,8 @@ void unloadPlaylist() {
|
||||
delete[] playlistEntries;
|
||||
playlistEntries = nullptr;
|
||||
}
|
||||
currentPlaylist = playlistIndex = -1;
|
||||
currentPlaylist = 0;
|
||||
playlistIndex = -1;
|
||||
playlistLen = playlistEntryDur = playlistOptions = 0;
|
||||
DEBUG_PRINTLN(F("Playlist unloaded."));
|
||||
}
|
||||
@ -118,7 +119,8 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) {
|
||||
|
||||
|
||||
void handlePlaylist() {
|
||||
if (currentPlaylist < 0 || playlistEntries == nullptr) return;
|
||||
static unsigned long presetCycledTime = 0;
|
||||
if (!currentPlaylist || playlistEntries == nullptr) return;
|
||||
|
||||
if (millis() - presetCycledTime > (100*playlistEntryDur)) {
|
||||
presetCycledTime = millis();
|
||||
|
@ -650,6 +650,9 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
||||
pos = req.indexOf(F("PS=")); //saves current in preset
|
||||
if (pos > 0) savePreset(getNumVal(&req, pos));
|
||||
|
||||
byte presetCycleMin = 1;
|
||||
byte presetCycleMax = 5;
|
||||
byte presetCycCurr;
|
||||
pos = req.indexOf(F("P1=")); //sets first preset for cycle
|
||||
if (pos > 0) presetCycleMin = getNumVal(&req, pos);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2110041
|
||||
#define VERSION 2110061
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -513,11 +513,7 @@ WLED_GLOBAL byte timerWeekday[] _INIT_N(({ 255, 255, 255, 255, 255, 255, 255, 25
|
||||
WLED_GLOBAL bool blynkEnabled _INIT(false);
|
||||
|
||||
//playlists
|
||||
WLED_GLOBAL unsigned long presetCycledTime _INIT(0);
|
||||
WLED_GLOBAL int16_t currentPlaylist _INIT(-1);
|
||||
//still used for "PL=~" HTTP API command
|
||||
WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5);
|
||||
WLED_GLOBAL byte presetCycCurr _INIT(presetCycleMin);
|
||||
WLED_GLOBAL byte currentPlaylist _INIT(0);
|
||||
|
||||
// realtime
|
||||
WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE);
|
||||
@ -569,7 +565,7 @@ WLED_GLOBAL JsonDocument* fileDoc;
|
||||
WLED_GLOBAL bool doCloseFile _INIT(false);
|
||||
|
||||
// presets
|
||||
WLED_GLOBAL int16_t currentPreset _INIT(-1);
|
||||
WLED_GLOBAL byte currentPreset _INIT(0);
|
||||
|
||||
WLED_GLOBAL byte errorFlag _INIT(0);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void XML_response(AsyncWebServerRequest *request, char* dest)
|
||||
oappend(SET_F("</wv><ws>"));
|
||||
oappendi(colSec[3]);
|
||||
oappend(SET_F("</ws><ps>"));
|
||||
oappendi((currentPreset < 1) ? 0:currentPreset);
|
||||
oappendi(currentPreset);
|
||||
oappend(SET_F("</ps><cy>"));
|
||||
oappendi(currentPlaylist > 0);
|
||||
oappend(SET_F("</cy><ds>"));
|
||||
|
Loading…
Reference in New Issue
Block a user