From bb7f673ff9cc023e3906e7a9e1603e5b66e146e1 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 17 Sep 2018 11:15:08 +0200 Subject: [PATCH] Re-added support for 512K flash ESPs --- wled00/htmls00.h | 3 +- wled00/htmls01.h | 22 +++ wled00/htmls02.h | 24 ++- wled00/palettes.h | 5 + wled00/wled00.ino | 11 +- wled00/wled03_set.ino | 309 +++++++++++++------------------------ wled00/wled05_init.ino | 6 +- wled00/wled11_ol.ino | 8 + wled00/wled13_cronixie.ino | 6 + 9 files changed, 181 insertions(+), 213 deletions(-) diff --git a/wled00/htmls00.h b/wled00/htmls00.h index 60d99520..32d15386 100644 --- a/wled00/htmls00.h +++ b/wled00/htmls00.h @@ -64,10 +64,11 @@ var displayElement=pr.getElementsByClassName("rangeValues")[0];displayElement.in )====="; #else const char PAGE_indexM[] PROGMEM = R"=====( -The Mobile UI is not supported due to limited flash storage. Please go to IP/settings/ui and change the UI mode to "Classic". +Mobile UI is unsupported (limited storage). Go to /settings/ui and change UI mode to "Classic". )====="; #endif + /* * Classic UI Index html */ diff --git a/wled00/htmls01.h b/wled00/htmls01.h index 52d5dbb6..43f11927 100644 --- a/wled00/htmls01.h +++ b/wled00/htmls01.h @@ -1,10 +1,14 @@ /* * Settings html */ + +//common CSS of settings pages const char PAGE_settingsCss[] PROGMEM = R"=====( body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%;margin:0;background-attachment:fixed}hr{border-color:var(--dCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}.helpB{text-align:left;position:absolute;width:60px}input{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.5ch solid var(--bCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}input[type=number]{width:3em}select{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:0.5ch solid var(--bCol);filter:drop-shadow( -5px -5px 5px var(--sCol) );} )====="; + +//settings menu const char PAGE_settings0[] PROGMEM = R"=====( WLED Settings @@ -26,11 +30,14 @@ body{text-align:center;background:var(--cCol);height:100%;margin:0;background-at )====="; + +//wifi settings const char PAGE_settings_wifi0[] PROGMEM = R"=====( WiFi Settings )====="; + const char PAGE_msg1[] PROGMEM = R"=====( button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%;margin:0;background-attachment:fixed} )====="; + +//new user welcome page +#ifndef WLED_FLASH_512K_MODE const char PAGE_welcome0[] PROGMEM = R"=====( WLED Welcome! )====="; + const char PAGE_welcome1[] PROGMEM = R"=====( body{font-family:var(--cFn),sans-serif;text-align:center;background:linear-gradient(var(--bCol),black);height:100%;margin:0;background-repeat:no-repeat;background-attachment: fixed;color: var(--tCol);}svg {fill: var(--dCol);} @@ -41,6 +50,11 @@ Connect the module to your local WiFi here!

Just trying this out in AP mode? Here are the controls.
)====="; +#else +const char PAGE_welcome0[] PROGMEM = ""; +const char PAGE_welcome1[] PROGMEM = ""; +#endif + /* * SPIFFS editor html @@ -54,6 +68,8 @@ eval(function(p,a,c,k,e,r){e=function(c){return(c= 0 && i <= 255) apWaitTimeSecs = i; - } - if (server.hasArg("AS")) strcpy(apSSID,server.arg("AS").c_str()); + strcpy(clientSSID,server.arg("CS").c_str()); + if (server.arg("CP").charAt(0) != '*') strcpy(clientPass, server.arg("CP").c_str()); + + strcpy(cmDNS, server.arg("CM").c_str()); + + int t = server.arg("AT").toInt(); if (t > 9 && t <= 255) apWaitTimeSecs = t; + strcpy(apSSID, server.arg("AS").c_str()); apHide = server.hasArg("AH"); - if (server.hasArg("AP")) - { - if (server.arg("AP").charAt(0) != '*') strcpy(apPass,server.arg("AP").c_str()); - } - if (server.hasArg("AC")) - { - int chan = server.arg("AC").toInt(); - if (chan > 0 && chan < 14) apChannel = chan; - } - char k[3]; k[2] = 0; int j = 0; + if (server.arg("AP").charAt(0) != '*') strcpy(apPass, server.arg("AP").c_str()); + t = server.arg("AC").toInt(); if (t > 0 && t < 14) apChannel = t; + + char k[3]; k[2] = 0; for (int i = 0; i<4; i++) { - k[1] = i+48; + k[1] = i+48;//ascii 0,1,2,3 + k[0] = 'I'; //static IP - if (server.hasArg(k)) j = server.arg(k).toInt(); - if (j >= 0 && j <= 255) staticIP[i] = j; + staticIP[i] = server.arg(k).toInt(); + k[0] = 'G'; //gateway - if (server.hasArg(k)) j = server.arg(k).toInt(); - if (j >= 0 && j <= 255) staticGateway[i] = j; + staticGateway[i] = server.arg(k).toInt(); + k[0] = 'S'; //subnet - if (server.hasArg(k)) j = server.arg(k).toInt(); - if (j >= 0 && j <= 255) staticSubnet[i] = j; + staticSubnet[i] = server.arg(k).toInt(); } } //LED SETTINGS if (subPage == 2) { - if (server.hasArg("LC")) - { - int i = server.arg("LC").toInt(); - if (i > 0 && i <= 1200) ledCount = i; - //RMT eats up too much RAM - #ifdef ARDUINO_ARCH_ESP32 - if (ledCount > 600) ledCount = 600; - #endif - } + int t = server.arg("LC").toInt(); + if (t > 0 && t <= 1200) ledCount = t; + //RMT eats up too much RAM + #ifdef ARDUINO_ARCH_ESP32 + if (ledCount > 600) ledCount = 600; + #endif useRGBW = server.hasArg("EW"); autoRGBtoRGBW = server.hasArg("AW"); if (server.hasArg("IS")) //ignore settings and save current brightness, colors and fx as default @@ -81,141 +66,75 @@ void handleSettingsSet(byte subPage) colS[0] = col[0]; colS[1] = col[1]; colS[2] = col[2]; - if (useRGBW) whiteS = white; + colSecS[0] = colSec[0]; + colSecS[1] = colSec[1]; + colSecS[2] = colSec[2]; + whiteS = white; + whiteSecS = whiteSec; briS = bri; effectDefault = effectCurrent; effectSpeedDefault = effectSpeed; effectIntensityDefault = effectIntensity; effectPaletteDefault = effectPalette; } else { - if (server.hasArg("CR")) - { - int i = server.arg("CR").toInt(); - if (i >= 0 && i <= 255) colS[0] = i; - } - if (server.hasArg("CG")) - { - int i = server.arg("CG").toInt(); - if (i >= 0 && i <= 255) colS[1] = i; - } - if (server.hasArg("CB")) - { - int i = server.arg("CB").toInt(); - if (i >= 0 && i <= 255) colS[2] = i; - } - if (server.hasArg("SR")) - { - int i = server.arg("SR").toInt(); - if (i >= 0 && i <= 255) colSecS[0] = i; - } - if (server.hasArg("SG")) - { - int i = server.arg("SG").toInt(); - if (i >= 0 && i <= 255) colSecS[1] = i; - } - if (server.hasArg("SB")) - { - int i = server.arg("SB").toInt(); - if (i >= 0 && i <= 255) colSecS[2] = i; - } - if (server.hasArg("SW")) - { - int i = server.arg("SW").toInt(); - if (i >= 0 && i <= 255) whiteSecS = i; - } - if (server.hasArg("CW")) - { - int i = server.arg("CW").toInt(); - if (i >= 0 && i <= 255) whiteS = i; - } - if (server.hasArg("CA")) - { - int i = server.arg("CA").toInt(); - if (i >= 0 && i <= 255) briS = i; - } - if (server.hasArg("FX")) - { - int i = server.arg("FX").toInt(); - if (i >= 0 && i <= 255) effectDefault = i; - } - if (server.hasArg("SX")) - { - int i = server.arg("SX").toInt(); - if (i >= 0 && i <= 255) effectSpeedDefault = i; - } - if (server.hasArg("IX")) - { - int i = server.arg("IX").toInt(); - if (i >= 0 && i <= 255) effectIntensityDefault = i; - } - if (server.hasArg("FP")) - { - int i = server.arg("FP").toInt(); - if (i >= 0 && i <= 255) effectPaletteDefault = i; - } + colS[0] = server.arg("CR").toInt(); + colS[1] = server.arg("CG").toInt(); + colS[2] = server.arg("CB").toInt(); + colSecS[0] = server.arg("SR").toInt(); + colSecS[1] = server.arg("SG").toInt(); + colSecS[2] = server.arg("SB").toInt(); + whiteS = server.arg("CW").toInt(); + whiteSecS = server.arg("SW").toInt(); + briS = server.arg("CA").toInt(); + effectDefault = server.arg("FX").toInt(); + effectSpeedDefault = server.arg("SX").toInt(); + effectIntensityDefault = server.arg("IX").toInt(); + effectPaletteDefault = server.arg("FP").toInt(); } saveCurrPresetCycConf = server.hasArg("PC"); turnOnAtBoot = server.hasArg("BO"); - if (server.hasArg("BP")) - { - int i = server.arg("BP").toInt(); - if (i >= 0 && i <= 25) bootPreset = i; - } + t = server.arg("BP").toInt(); + if (t <= 25) bootPreset = t; useGammaCorrectionBri = server.hasArg("GB"); useGammaCorrectionRGB = server.hasArg("GC"); + fadeTransition = server.hasArg("TF"); - if (server.hasArg("TD")) - { - int i = server.arg("TD").toInt(); - if (i > 0){ - transitionDelay = i; - } - } + t = server.arg("TD").toInt(); + if (t > 0) transitionDelay = t; strip.paletteFade = server.hasArg("PF"); enableSecTransition = server.hasArg("T2"); - if (server.hasArg("TB")) - { - nightlightTargetBri = server.arg("TB").toInt(); - } - if (server.hasArg("TL")) - { - int i = server.arg("TL").toInt(); - if (i > 0) nightlightDelayMins = i; - } + + nightlightTargetBri = server.arg("TB").toInt(); + t = server.arg("TL").toInt(); + if (t > 0) nightlightDelayMins = t; nightlightFade = server.hasArg("TW"); - reverseMode = server.hasArg("RV"); - if (server.hasArg("PB")) - { - int i = server.arg("PB").toInt(); - if (i >= 0){ - strip.paletteBlend = i; - } - } + + t = server.arg("PB").toInt(); + if (t >= 0 && t < 4) strip.paletteBlend = t; initLedsLast = server.hasArg("EI"); + reverseMode = server.hasArg("RV"); strip.setReverseMode(reverseMode); skipFirstLed = server.hasArg("SL"); - if (server.hasArg("BF")) - { - int i = server.arg("BF").toInt(); - if (i > 0) briMultiplier = i; - } + t = server.arg("BF").toInt(); + if (t > 0) briMultiplier = t; } //UI if (subPage == 3) { - if (server.hasArg("UI")) uiConfiguration = server.arg("UI").toInt(); - if (server.hasArg("DS")) strcpy(serverDescription,server.arg("DS").c_str()); + int t = server.arg("UI").toInt(); + if (t >= 0 && t < 3) uiConfiguration = t; + strcpy(serverDescription, server.arg("DS").c_str()); useHSBDefault = server.hasArg("MD"); useHSB = useHSBDefault; - if (server.hasArg("TH")) currentTheme = server.arg("TH").toInt(); + currentTheme = server.arg("TH").toInt(); char k[3]; k[0]='C'; k[2]=0; for(int i=0;i<6;i++) { k[1] = i+48; - if (server.hasArg(k)) strcpy(cssCol[i],server.arg(k).c_str()); + strcpy(cssCol[i],server.arg(k).c_str()); } - if (server.hasArg("CF")) strcpy(cssFont,server.arg("CF").c_str()); + strcpy(cssFont,server.arg("CF").c_str()); buildCssColorString(); } @@ -223,10 +142,8 @@ void handleSettingsSet(byte subPage) if (subPage == 4) { buttonEnabled = server.hasArg("BT"); - if (server.hasArg("UP")) - { - udpPort = server.arg("UP").toInt(); - } + int t = server.arg("UP").toInt(); + if (t > 0) udpPort = t; receiveNotificationBrightness = server.hasArg("RB"); receiveNotificationColor = server.hasArg("RC"); receiveNotificationEffects = server.hasArg("RX"); @@ -235,45 +152,36 @@ void handleSettingsSet(byte subPage) notifyDirect = notifyDirectDefault; notifyButton = server.hasArg("SB"); notifyTwice = server.hasArg("S2"); + receiveDirect = server.hasArg("RD"); - if (server.hasArg("EU")) - { - int i = server.arg("EU").toInt(); - if (i > 0 && i <= 63999) realtimeTimeoutMs = i; - } - if (server.hasArg("ET")) - { - int i = server.arg("ET").toInt(); - if (i > 99 && i <= 65000) realtimeTimeoutMs = i; - } + t = server.arg("EU").toInt(); + if (t > 0 && t <= 63999) e131Universe = t; + t = server.arg("ET").toInt(); + if (t > 99 && t <= 65000) realtimeTimeoutMs = t; arlsForceMaxBri = server.hasArg("FB"); arlsDisableGammaCorrection = server.hasArg("RG"); - if (server.hasArg("WO")) - { - int i = server.arg("WO").toInt(); - if (i >= -255 && i <= 255) arlsOffset = i; - } + t = server.arg("WO").toInt(); + if (t >= -255 && t <= 255) arlsOffset = t; enableRealtimeUI = server.hasArg("RU"); + alexaEnabled = server.hasArg("AL"); - if (server.hasArg("AI")) strcpy(alexaInvocationName,server.arg("AI").c_str()); + strcpy(alexaInvocationName, server.arg("AI").c_str()); notifyAlexa = server.hasArg("SA"); + if (server.hasArg("BK") && !server.arg("BK").equals("Hidden")) {strcpy(blynkApiKey,server.arg("BK").c_str()); initBlynk(blynkApiKey);} + notifyHue = server.hasArg("SH"); for (int i=0;i<4;i++){ String a = "H"+String(i); - if (server.hasArg(a)) - hueIP[i] = server.arg(a).toInt(); - } - if (server.hasArg("HL")) - { - int i = server.arg("HL").toInt(); - if (i > 0) huePollLightId = i; - } - if (server.hasArg("HI")) - { - int i = server.arg("HI").toInt(); - if (i > 50) huePollIntervalMs = i; + hueIP[i] = server.arg(a).toInt(); } + + t = server.arg("HL").toInt(); + if (t > 0) huePollLightId = t; + + t = server.arg("HI").toInt(); + if (t > 50) huePollIntervalMs = t; + hueApplyOnOff = server.hasArg("HO"); hueApplyBri = server.hasArg("HB"); hueApplyColor = server.hasArg("HC"); @@ -293,22 +201,22 @@ void handleSettingsSet(byte subPage) { ntpEnabled = server.hasArg("NT"); useAMPM = !server.hasArg("CF"); - if (server.hasArg("TZ")) currentTimezone = server.arg("TZ").toInt(); - if (server.hasArg("UO")) utcOffsetSecs = server.arg("UO").toInt(); + currentTimezone = server.arg("TZ").toInt(); + utcOffsetSecs = server.arg("UO").toInt(); if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); //start if not already connected if (server.hasArg("OL")){ overlayDefault = server.arg("OL").toInt(); overlayCurrent = overlayDefault; - ; } - if (server.hasArg("O1")) overlayMin = server.arg("O1").toInt(); - if (server.hasArg("O2")) overlayMax = server.arg("O2").toInt(); - if (server.hasArg("OM")) analogClock12pixel = server.arg("OM").toInt(); + + overlayMin = server.arg("O1").toInt(); + overlayMax = server.arg("O2").toInt(); + analogClock12pixel = server.arg("OM").toInt(); analogClock5MinuteMarks = server.hasArg("O5"); analogClockSecondsTrail = server.hasArg("OS"); - if (server.hasArg("CX")) strcpy(cronixieDisplay,server.arg("CX").c_str()); + strcpy(cronixieDisplay,server.arg("CX").c_str()); bool cbOld = cronixieBacklight; cronixieBacklight = server.hasArg("CB"); if (cbOld != cronixieBacklight && overlayCurrent == 4) @@ -316,25 +224,25 @@ void handleSettingsSet(byte subPage) strip.setCronixieBacklight(cronixieBacklight); overlayRefreshedTime = 0; } countdownMode = server.hasArg("CE"); - if (server.hasArg("CY")) countdownYear = server.arg("CY").toInt(); - if (server.hasArg("CI")) countdownMonth = server.arg("CI").toInt(); - if (server.hasArg("CD")) countdownDay = server.arg("CD").toInt(); - if (server.hasArg("CH")) countdownHour = server.arg("CH").toInt(); - if (server.hasArg("CM")) countdownMin = server.arg("CM").toInt(); - if (server.hasArg("CS")) countdownSec = server.arg("CS").toInt(); + countdownYear = server.arg("CY").toInt(); + countdownMonth = server.arg("CI").toInt(); + countdownDay = server.arg("CD").toInt(); + countdownHour = server.arg("CH").toInt(); + countdownMin = server.arg("CM").toInt(); + countdownSec = server.arg("CS").toInt(); for (int i=1;i<17;i++) { String a = "M"+String(i); if (server.hasArg(a)) saveMacro(i,server.arg(a),false); } - if (server.hasArg("MB")) macroBoot = server.arg("MB").toInt(); - if (server.hasArg("A0")) macroAlexaOn = server.arg("A0").toInt(); - if (server.hasArg("A1")) macroAlexaOff = server.arg("A1").toInt(); - if (server.hasArg("MP")) macroButton = server.arg("MP").toInt(); - if (server.hasArg("ML")) macroLongPress = server.arg("ML").toInt(); - if (server.hasArg("MC")) macroCountdown = server.arg("MC").toInt(); - if (server.hasArg("MN")) macroNl = server.arg("MN").toInt(); + macroBoot = server.arg("MB").toInt(); + macroAlexaOn = server.arg("A0").toInt(); + macroAlexaOff = server.arg("A1").toInt(); + macroButton = server.arg("MP").toInt(); + macroLongPress = server.arg("ML").toInt(); + macroCountdown = server.arg("MC").toInt(); + macroNl = server.arg("MN").toInt(); } //SECURITY @@ -375,9 +283,8 @@ void handleSettingsSet(byte subPage) bool handleSet(String req) { bool effectUpdated = false; - if (!(req.indexOf("win") >= 0)) { - return false; - } + if (!(req.indexOf("win") >= 0)) return false; + int pos = 0; DEBUG_PRINT("API req: "); DEBUG_PRINTLN(req); diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index a717f751..00472f9a 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -118,7 +118,7 @@ void wledInit() server.on("/settings/wifi", HTTP_POST, [](){ if (!(wifiLock && otaLock)) handleSettingsSet(1); - serveMessage(200,"WiFi settings saved.","Rebooting now... (takes ~20 seconds, wait for auto-redirect)",139); + serveMessage(200,"WiFi settings saved.","Rebooting now...",255); reset(); }); @@ -488,6 +488,10 @@ void serveSettings(byte subPage) //0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage if (!realtimeActive || enableRealtimeUI) //do not serve while receiving realtime { + #ifdef WLED_FLASH_512K_MODE //disable welcome page if not enough storage + if (subPage == 255) {serveIndex(); return;} + #endif + int pl0, pl1; switch (subPage) { diff --git a/wled00/wled11_ol.ino b/wled00/wled11_ol.ino index 8695d51a..969a3e1a 100644 --- a/wled00/wled11_ol.ino +++ b/wled00/wled11_ol.ino @@ -16,6 +16,7 @@ void initCronixie() } } + void _nixieDisplay(int num[], uint16_t dur[], uint16_t pausedur[], byte cnt) { strip.setRange(overlayMin, overlayMax, 0); @@ -116,6 +117,7 @@ void _nixieNumber(int number, int dur) } } + void handleOverlays() { if (millis() - overlayRefreshedTime > overlayRefreshMs) @@ -181,6 +183,10 @@ void _overlayAnalogClock() void _overlayNixieClock() { + #ifdef WLED_FLASH_512K_MODE + if (countdownMode) checkCountdown(); + #else + if (countdownMode) { _overlayNixieCountdown(); return; @@ -265,6 +271,7 @@ void _overlayNixieClock() { _nixieDisplay(overlayArr, overlayDur, overlayPauseDur, 6); } + #endif } void _overlayAnalogCountdown() @@ -312,6 +319,7 @@ void _overlayAnalogCountdown() overlayRefreshMs = 998; } + void _overlayNixieCountdown() { if (now() >= countdownTime) diff --git a/wled00/wled13_cronixie.ino b/wled00/wled13_cronixie.ino index ae31072a..845aaf69 100644 --- a/wled00/wled13_cronixie.ino +++ b/wled00/wled13_cronixie.ino @@ -19,6 +19,7 @@ byte getSameCodeLength(char code, int index, char const cronixieDisplay[]) void setCronixie() { + #ifndef WLED_FLASH_512K_MODE /* * digit purpose index * 0-9 | 0-9 (incl. random) @@ -139,11 +140,14 @@ void setCronixie() DEBUG_PRINTLN((int)dP[5]); _overlayCronixie(); //refresh + #endif } void _overlayCronixie() { if (countdownMode) checkCountdown(); + #ifndef WLED_FLASH_512K_MODE + byte h = hour(local); byte h0 = h; byte m = minute(local); @@ -208,4 +212,6 @@ void _overlayCronixie() } strip.setCronixieDigits(_digitOut); //strip.trigger(); //this has a drawback, no effects slower than RefreshMs. advantage: Quick update, not dependant on effect time + #endif } +