Removed preset cycle

This commit is contained in:
cschwinne 2021-06-30 01:48:38 +02:00
parent 599a456c81
commit 200960899e
11 changed files with 31 additions and 126 deletions

View File

@ -5,6 +5,8 @@
#### Build 2106300 #### Build 2106300
- Version bump to 0.13.0-b0 "Toki" - 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 - Added playlist editor UI
- Reordered segment UI and added offset field - Reordered segment UI and added offset field
- Raised maximum MQTT password length to 64 (closes #1373) - Raised maximum MQTT password length to 64 (closes #1373)

View File

@ -222,15 +222,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(turnOnAtBoot, def["on"]); // true CJSON(turnOnAtBoot, def["on"]); // true
CJSON(briS, def["bri"]); // 128 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 interfaces = doc["if"];
JsonObject if_sync = interfaces[F("sync")]; JsonObject if_sync = interfaces[F("sync")];
@ -588,17 +579,6 @@ void serializeConfig() {
def["on"] = turnOnAtBoot; def["on"] = turnOnAtBoot;
def["bri"] = briS; 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 interfaces = doc.createNestedObject("if");
JsonObject if_sync = interfaces.createNestedObject("sync"); JsonObject if_sync = interfaces.createNestedObject("sync");

View File

@ -366,8 +366,7 @@ Reverse (rotated 180°): <input type="checkbox" name="CV${i}">
Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br> Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br>
Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br><br> Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br><br>
Apply preset <input name="BP" type="number" min="0" max="250" required> at boot (0 uses defaults) Apply preset <input name="BP" type="number" min="0" max="250" required> at boot (0 uses defaults)
<br>- <i>or</i> -<br> <br><br>
Set current preset cycle setting as boot default: <input type="checkbox" name="PC"><br><br>
Use Gamma correction for color: <input type="checkbox" name="GC"> (strongly recommended)<br> Use Gamma correction for color: <input type="checkbox" name="GC"> (strongly recommended)<br>
Use Gamma correction for brightness: <input type="checkbox" name="GB"> (not recommended)<br><br> Use Gamma correction for brightness: <input type="checkbox" name="GB"> (not recommended)<br><br>
Brightness factor: <input name="BF" type="number" min="1" max="255" required> % Brightness factor: <input name="BF" type="number" min="1" max="255" required> %

View File

@ -128,28 +128,27 @@ type="checkbox" name="RM"><span style="cursor:pointer" onclick='off("RL")'>
Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br> Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br>
Default brightness: <input name="CA" type="number" min="0" max="255" required> Default brightness: <input name="CA" type="number" min="0" max="255" required>
(0-255)<br><br>Apply preset <input name="BP" type="number" min="0" max="250" (0-255)<br><br>Apply preset <input name="BP" type="number" min="0" max="250"
required> at boot (0 uses defaults)<br>- <i>or</i> -<br> required> at boot (0 uses defaults)<br><br>Use Gamma correction for color:
Set current preset cycle setting as boot default: <input type="checkbox" <input type="checkbox" name="GC"> (strongly recommended)<br>
name="PC"><br><br>Use Gamma correction for color: <input type="checkbox" Use Gamma correction for brightness: <input type="checkbox" name="GB">
name="GC"> (strongly recommended)<br>Use Gamma correction for brightness: <input (not recommended)<br><br>Brightness factor: <input name="BF" type="number"
type="checkbox" name="GB"> (not recommended)<br><br>Brightness factor: <input min="1" max="255" required> %<h3>Transitions</h3>Crossfade: <input
name="BF" type="number" min="1" max="255" required> %<h3>Transitions</h3> type="checkbox" name="TF"><br>Transition Time: <input name="TD" maxlength="5"
Crossfade: <input type="checkbox" name="TF"><br>Transition Time: <input size="2"> ms<br>Enable Palette transitions: <input type="checkbox" name="PF">
name="TD" maxlength="5" size="2"> ms<br>Enable Palette transitions: <input <h3>Timed light</h3>Default Duration: <input name="TL" type="number" min="1"
type="checkbox" name="PF"><h3>Timed light</h3>Default Duration: <input max="255" required> min<br>Default Target brightness: <input name="TB"
name="TL" type="number" min="1" max="255" required> min<br> type="number" min="0" max="255" required><br>Mode: <select name="TW"><option
Default Target brightness: <input name="TB" type="number" min="0" max="255" value="0">Wait and set</option><option value="1">Fade</option><option value="2">
required><br>Mode: <select name="TW"><option value="0">Wait and set</option> Fade Color</option><option value="3">Sunrise</option></select><h3>Advanced</h3>
<option value="1">Fade</option><option value="2">Fade Color</option><option Palette blending: <select name="PB"><option value="0">Linear (wrap if moving)
value="3">Sunrise</option></select><h3>Advanced</h3>Palette blending: <select </option><option value="1">Linear (always wrap)</option><option value="2">
name="PB"><option value="0">Linear (wrap if moving)</option><option value="1"> Linear (never wrap)</option><option value="3">None (not recommended)</option>
Linear (always wrap)</option><option value="2">Linear (never wrap)</option> </select><br><span class="wc">Auto-calculate white channel from RGB:<br><select
<option value="3">None (not recommended)</option></select><br><span class="wc"> name="AW"><option value="0">None</option><option value="1">Brighter</option>
Auto-calculate white channel from RGB:<br><select name="AW"><option value="0"> <option value="2">Accurate</option><option value="3">Dual</option><option
None</option><option value="1">Brighter</option><option value="2">Accurate value="4">Legacy</option></select><br></span><hr><button type="button"
</option><option value="3">Dual</option><option value="4">Legacy</option> onclick="B()">Back</button><button type="submit">Save</button></form></body>
</select><br></span><hr><button type="button" onclick="B()">Back</button><button </html>)=====";
type="submit">Save</button></form></body></html>)=====";
#ifdef WLED_ENABLE_DMX #ifdef WLED_ENABLE_DMX

View File

@ -197,19 +197,10 @@ bool deserializeState(JsonObject root, byte presetId)
tr = root[F("tb")] | -1; tr = root[F("tb")] | -1;
if (tr >= 0) strip.timebase = ((uint32_t)tr) - millis(); 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"]; JsonObject nl = root["nl"];
nightlightActive = nl["on"] | nightlightActive; nightlightActive = nl["on"] | nightlightActive;
nightlightDelayMins = nl[F("dur")] | nightlightDelayMins; nightlightDelayMins = nl[F("dur")] | nightlightDelayMins;
nightlightMode = nl[F("fade")] | nightlightMode; //deprecated, remove for v0.13.0
nightlightMode = nl[F("mode")] | nightlightMode; nightlightMode = nl[F("mode")] | nightlightMode;
nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri; 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; if (errorFlag) root[F("error")] = errorFlag;
root[F("ps")] = currentPreset; root[F("ps")] = currentPreset;
root[F("pl")] = (presetCyclingEnabled) ? 0: -1; root[F("pl")] = currentPlaylist;
usermods.addToJsonState(root); 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"); JsonObject nl = root.createNestedObject("nl");
nl["on"] = nightlightActive; nl["on"] = nightlightActive;
nl[F("dur")] = nightlightDelayMins; nl[F("dur")] = nightlightDelayMins;
nl[F("fade")] = (nightlightMode > NL_MODE_SET); //deprecated
nl[F("mode")] = nightlightMode; nl[F("mode")] = nightlightMode;
nl[F("tbri")] = nightlightTargetBri; nl[F("tbri")] = nightlightTargetBri;
if (nightlightActive) { if (nightlightActive) {
@ -451,9 +435,6 @@ void serializeInfo(JsonObject root)
leds[F("count")] = ledCount; leds[F("count")] = ledCount;
leds[F("rgbw")] = strip.isRgbw; 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? 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("pwr")] = strip.currentMilliamps;
leds[F("fps")] = strip.getFps(); leds[F("fps")] = strip.getFps();
leds[F("maxpwr")] = (strip.currentMilliamps)? strip.ablMilliampsMax : 0; leds[F("maxpwr")] = (strip.currentMilliamps)? strip.ablMilliampsMax : 0;

View File

@ -296,19 +296,6 @@ void handleNightlight()
} }
nightlightActiveOld = false; 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 //utility for FastLED to use our custom timer

View File

@ -117,7 +117,7 @@ void loadPlaylist(JsonObject playlistObj, byte presetId) {
void handlePlaylist() { void handlePlaylist() {
if (currentPlaylist < 0 || playlistEntries == nullptr || presetCyclingEnabled) return; if (currentPlaylist < 0 || playlistEntries == nullptr) return;
if (millis() - presetCycledTime > (100*playlistEntryDur)) { if (millis() - presetCycledTime > (100*playlistEntryDur)) {
presetCycledTime = millis(); presetCycledTime = millis();

View File

@ -164,7 +164,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
briS = request->arg(F("CA")).toInt(); briS = request->arg(F("CA")).toInt();
saveCurrPresetCycConf = request->hasArg(F("PC"));
turnOnAtBoot = request->hasArg(F("BO")); turnOnAtBoot = request->hasArg(F("BO"));
t = request->arg(F("BP")).toInt(); t = request->arg(F("BP")).toInt();
if (t <= 250) bootPreset = t; 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); 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 pos = req.indexOf(F("PS=")); //saves current in preset
if (pos > 0) savePreset(getNumVal(&req, pos)); if (pos > 0) savePreset(getNumVal(&req, pos));
//apply preset //apply preset
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) { pos = req.indexOf(F("PL="));
applyPreset(presetCycCurr); if (pos > 0) applyPreset(getNumVal(&req, pos));
}
//set brightness //set brightness
updateVal(&req, "&A=", &bri); updateVal(&req, "&A=", &bri);
@ -733,7 +708,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
} }
//set effect parameters //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, "SX=", &effectSpeed);
updateVal(&req, "IX=", &effectIntensity); updateVal(&req, "IX=", &effectIntensity);
updateVal(&req, "FP=", &effectPalette, 0, strip.getPaletteCount()-1); updateVal(&req, "FP=", &effectPalette, 0, strip.getPaletteCount()-1);

View File

@ -500,14 +500,8 @@ WLED_GLOBAL byte timerWeekday[] _INIT_N(({ 255, 255, 255, 255, 255, 255, 255, 25
// blynk // blynk
WLED_GLOBAL bool blynkEnabled _INIT(false); WLED_GLOBAL bool blynkEnabled _INIT(false);
// preset cycling //playlists
WLED_GLOBAL bool presetCyclingEnabled _INIT(false);
WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5);
WLED_GLOBAL uint16_t presetCycleTime _INIT(12);
WLED_GLOBAL unsigned long presetCycledTime _INIT(0); 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); WLED_GLOBAL int16_t currentPlaylist _INIT(0);
// realtime // realtime

View File

@ -323,18 +323,6 @@ void loadSettingsFromEEPROM()
strip.rgbwMode = EEPROM.read(2203); strip.rgbwMode = EEPROM.read(2203);
//skipFirstLed = EEPROM.read(2204); //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); bootPreset = EEPROM.read(389);
wifiLock = EEPROM.read(393); wifiLock = EEPROM.read(393);
utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00); utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00);

View File

@ -61,7 +61,7 @@ void XML_response(AsyncWebServerRequest *request, char* dest)
oappend(SET_F("</ws><ps>")); oappend(SET_F("</ws><ps>"));
oappendi((currentPreset < 1) ? 0:currentPreset); oappendi((currentPreset < 1) ? 0:currentPreset);
oappend(SET_F("</ps><cy>")); oappend(SET_F("</ps><cy>"));
oappendi(presetCyclingEnabled); oappendi(currentPlaylist > 0);
oappend(SET_F("</cy><ds>")); oappend(SET_F("</cy><ds>"));
oappend(serverDescription); oappend(serverDescription);
if (realtimeMode) if (realtimeMode)