From 200960899e2a5311235099b45f231aee816ecd90 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 30 Jun 2021 01:48:38 +0200 Subject: [PATCH] Removed preset cycle --- CHANGELOG.md | 2 ++ wled00/cfg.cpp | 20 ---------------- wled00/data/settings_leds.htm | 3 +-- wled00/html_settings.h | 43 +++++++++++++++++------------------ wled00/json.cpp | 21 +---------------- wled00/led.cpp | 13 ----------- wled00/playlist.cpp | 2 +- wled00/set.cpp | 31 +++---------------------- wled00/wled.h | 8 +------ wled00/wled_eeprom.cpp | 12 ---------- wled00/xml.cpp | 2 +- 11 files changed, 31 insertions(+), 126 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3885632f..e8adcd89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ #### Build 2106300 - Version bump to 0.13.0-b0 "Toki" +- BREAKING: Removed preset cycle (use playlists) +- BREAKING: Removed `nl.fade`, `leds.pin` and `ccnf` from JSON API - Added playlist editor UI - Reordered segment UI and added offset field - Raised maximum MQTT password length to 64 (closes #1373) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 247acfd9..e594f2b7 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -222,15 +222,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(turnOnAtBoot, def["on"]); // true CJSON(briS, def["bri"]); // 128 - JsonObject def_cy = def[F("cy")]; - CJSON(presetCyclingEnabled, def_cy["on"]); - - CJSON(presetCycleMin, def_cy[F("range")][0]); - CJSON(presetCycleMax, def_cy[F("range")][1]); - - tdd = def_cy["dur"] | -1; - if (tdd > 0) presetCycleTime = tdd; - JsonObject interfaces = doc["if"]; JsonObject if_sync = interfaces[F("sync")]; @@ -588,17 +579,6 @@ void serializeConfig() { def["on"] = turnOnAtBoot; def["bri"] = briS; - //to be removed once preset cycles are presets - if (saveCurrPresetCycConf) { - JsonObject def_cy = def.createNestedObject("cy"); - def_cy["on"] = presetCyclingEnabled; - - JsonArray def_cy_range = def_cy.createNestedArray(F("range")); - def_cy_range.add(presetCycleMin); - def_cy_range.add(presetCycleMax); - def_cy["dur"] = presetCycleTime; - } - JsonObject interfaces = doc.createNestedObject("if"); JsonObject if_sync = interfaces.createNestedObject("sync"); diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index b24648fb..53c93576 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -366,8 +366,7 @@ Reverse (rotated 180°): Turn LEDs on after power up/reset:
Default brightness: (0-255)

Apply preset at boot (0 uses defaults) -
- or -
- Set current preset cycle setting as boot default:

+

Use Gamma correction for color: (strongly recommended)
Use Gamma correction for brightness: (not recommended)

Brightness factor: % diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 213cdc92..4544cb67 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -128,28 +128,27 @@ type="checkbox" name="RM"> Turn LEDs on after power up/reset:
Default brightness: (0-255)

Apply preset at boot (0 uses defaults)
- or -
-Set current preset cycle setting as boot default:

Use Gamma correction for color: (strongly recommended)
Use Gamma correction for brightness: (not recommended)

Brightness factor: %

Transitions

-Crossfade:
Transition Time: ms
Enable Palette transitions:

Timed light

Default Duration: min
-Default Target brightness:
Mode:

Advanced

Palette blending:
-Auto-calculate white channel from RGB:


)====="; +required> at boot (0 uses defaults)

Use Gamma correction for color: + (strongly recommended)
+Use Gamma correction for brightness: + (not recommended)

Brightness factor: %

Transitions

Crossfade:
Transition Time: ms
Enable Palette transitions: +

Timed light

Default Duration: min
Default Target brightness:
Mode:

Advanced

+Palette blending:
Auto-calculate white channel from RGB:


+)====="; #ifdef WLED_ENABLE_DMX diff --git a/wled00/json.cpp b/wled00/json.cpp index 7d9c5896..5c5ef479 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -197,19 +197,10 @@ bool deserializeState(JsonObject root, byte presetId) tr = root[F("tb")] | -1; if (tr >= 0) strip.timebase = ((uint32_t)tr) - millis(); - - int cy = root[F("pl")] | -2; - if (cy > -2) presetCyclingEnabled = (cy >= 0); - JsonObject ccnf = root["ccnf"]; - presetCycleMin = ccnf[F("min")] | presetCycleMin; - presetCycleMax = ccnf[F("max")] | presetCycleMax; - tr = ccnf[F("time")] | -1; - if (tr >= 2) presetCycleTime = tr; JsonObject nl = root["nl"]; nightlightActive = nl["on"] | nightlightActive; nightlightDelayMins = nl[F("dur")] | nightlightDelayMins; - nightlightMode = nl[F("fade")] | nightlightMode; //deprecated, remove for v0.13.0 nightlightMode = nl[F("mode")] | nightlightMode; nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri; @@ -375,20 +366,13 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme if (errorFlag) root[F("error")] = errorFlag; root[F("ps")] = currentPreset; - root[F("pl")] = (presetCyclingEnabled) ? 0: -1; + root[F("pl")] = currentPlaylist; usermods.addToJsonState(root); - //temporary for preset cycle - JsonObject ccnf = root.createNestedObject("ccnf"); - ccnf[F("min")] = presetCycleMin; - ccnf[F("max")] = presetCycleMax; - ccnf[F("time")] = presetCycleTime; - JsonObject nl = root.createNestedObject("nl"); nl["on"] = nightlightActive; nl[F("dur")] = nightlightDelayMins; - nl[F("fade")] = (nightlightMode > NL_MODE_SET); //deprecated nl[F("mode")] = nightlightMode; nl[F("tbri")] = nightlightTargetBri; if (nightlightActive) { @@ -451,9 +435,6 @@ void serializeInfo(JsonObject root) leds[F("count")] = ledCount; leds[F("rgbw")] = strip.isRgbw; leds[F("wv")] = strip.isRgbw && (strip.rgbwMode == RGBW_MODE_MANUAL_ONLY || strip.rgbwMode == RGBW_MODE_DUAL); //should a white channel slider be displayed? - JsonArray leds_pin = leds.createNestedArray("pin"); - leds_pin.add(LEDPIN); - leds[F("pwr")] = strip.currentMilliamps; leds[F("fps")] = strip.getFps(); leds[F("maxpwr")] = (strip.currentMilliamps)? strip.ablMilliampsMax : 0; diff --git a/wled00/led.cpp b/wled00/led.cpp index 9abe9412..344bc2a4 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -296,19 +296,6 @@ void handleNightlight() } nightlightActiveOld = false; } - - //also handle preset cycle here - if (presetCyclingEnabled && (millis() - presetCycledTime > (100*presetCycleTime))) - { - presetCycledTime = millis(); - if (bri == 0 || nightlightActive) return; - - if (presetCycCurr < presetCycleMin || presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin; - applyPreset(presetCycCurr); //this handles colorUpdated() for us - presetCycCurr++; - if (presetCycCurr > 250) presetCycCurr = 1; - interfaceUpdateCallMode = 0; //disable updates to MQTT and Blynk - } } //utility for FastLED to use our custom timer diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index ed45220b..6f46bbf9 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -117,7 +117,7 @@ void loadPlaylist(JsonObject playlistObj, byte presetId) { void handlePlaylist() { - if (currentPlaylist < 0 || playlistEntries == nullptr || presetCyclingEnabled) return; + if (currentPlaylist < 0 || playlistEntries == nullptr) return; if (millis() - presetCycledTime > (100*playlistEntryDur)) { presetCycledTime = millis(); diff --git a/wled00/set.cpp b/wled00/set.cpp index c0a1f7c0..7fc62c5c 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -164,7 +164,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) briS = request->arg(F("CA")).toInt(); - saveCurrPresetCycConf = request->hasArg(F("PC")); turnOnAtBoot = request->hasArg(F("BO")); t = request->arg(F("BP")).toInt(); if (t <= 250) bootPreset = t; @@ -611,36 +610,12 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) } strip.setSegment(selectedSeg, startI, stopI, grpI, spcI); - //set presets - pos = req.indexOf(F("P1=")); //sets first preset for cycle - if (pos > 0) presetCycleMin = getNumVal(&req, pos); - - pos = req.indexOf(F("P2=")); //sets last preset for cycle - if (pos > 0) presetCycleMax = getNumVal(&req, pos); - - //preset cycle - pos = req.indexOf(F("CY=")); - if (pos > 0) - { - char cmd = req.charAt(pos+3); - if (cmd == '2') presetCyclingEnabled = !presetCyclingEnabled; - else presetCyclingEnabled = (cmd != '0'); - presetCycCurr = presetCycleMin; - } - - pos = req.indexOf(F("PT=")); //sets cycle time in ms - if (pos > 0) { - int v = getNumVal(&req, pos); - if (v > 100) presetCycleTime = v/100; - } - pos = req.indexOf(F("PS=")); //saves current in preset if (pos > 0) savePreset(getNumVal(&req, pos)); //apply preset - if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) { - applyPreset(presetCycCurr); - } + pos = req.indexOf(F("PL=")); + if (pos > 0) applyPreset(getNumVal(&req, pos)); //set brightness updateVal(&req, "&A=", &bri); @@ -733,7 +708,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply) } //set effect parameters - if (updateVal(&req, "FX=", &effectCurrent, 0, strip.getModeCount()-1)) presetCyclingEnabled = false; + if (updateVal(&req, "FX=", &effectCurrent, 0, strip.getModeCount()-1)) unloadPlaylist(); updateVal(&req, "SX=", &effectSpeed); updateVal(&req, "IX=", &effectIntensity); updateVal(&req, "FP=", &effectPalette, 0, strip.getPaletteCount()-1); diff --git a/wled00/wled.h b/wled00/wled.h index 395f392e..c04a3b6b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -500,14 +500,8 @@ WLED_GLOBAL byte timerWeekday[] _INIT_N(({ 255, 255, 255, 255, 255, 255, 255, 25 // blynk WLED_GLOBAL bool blynkEnabled _INIT(false); -// preset cycling -WLED_GLOBAL bool presetCyclingEnabled _INIT(false); -WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5); -WLED_GLOBAL uint16_t presetCycleTime _INIT(12); +//playlists WLED_GLOBAL unsigned long presetCycledTime _INIT(0); -WLED_GLOBAL byte presetCycCurr _INIT(presetCycleMin); -WLED_GLOBAL bool saveCurrPresetCycConf _INIT(false); - WLED_GLOBAL int16_t currentPlaylist _INIT(0); // realtime diff --git a/wled00/wled_eeprom.cpp b/wled00/wled_eeprom.cpp index bab8d305..675830e9 100644 --- a/wled00/wled_eeprom.cpp +++ b/wled00/wled_eeprom.cpp @@ -323,18 +323,6 @@ void loadSettingsFromEEPROM() strip.rgbwMode = EEPROM.read(2203); //skipFirstLed = EEPROM.read(2204); - if (EEPROM.read(2210) || EEPROM.read(2211) || EEPROM.read(2212)) - { - presetCyclingEnabled = EEPROM.read(2205); - presetCycleTime = EEPROM.read(2206) + ((EEPROM.read(2207) << 8) & 0xFF00); - if (lastEEPROMversion < 21) presetCycleTime /= 100; //was stored in ms, now is in tenths of a second - presetCycleMin = EEPROM.read(2208); - presetCycleMax = EEPROM.read(2209); - //was presetApplyBri = EEPROM.read(2210); - //was presetApplyCol = EEPROM.read(2211); - //was presetApplyFx = EEPROM.read(2212); - } - bootPreset = EEPROM.read(389); wifiLock = EEPROM.read(393); utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index fcc729d7..c12991fe 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -61,7 +61,7 @@ void XML_response(AsyncWebServerRequest *request, char* dest) oappend(SET_F("")); oappendi((currentPreset < 1) ? 0:currentPreset); oappend(SET_F("")); - oappendi(presetCyclingEnabled); + oappendi(currentPlaylist > 0); oappend(SET_F("")); oappend(serverDescription); if (realtimeMode)