From b72e6f16caf56249652ec1c4bc148c44fab4a13b Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 9 Mar 2019 21:41:23 +0100 Subject: [PATCH] Small memory improvements --- wled00/WS2812FX.h | 7 +++---- wled00/data/update.htm | 4 ++++ wled00/html_other.h | 14 ++++++++++---- wled00/wled00.ino | 5 ++--- wled00/wled02_xml.ino | 2 +- wled00/wled03_set.ino | 6 +++--- wled00/wled05_init.ino | 2 +- wled00/wled16_blynk.ino | 5 +++-- wled00/wled18_server.ino | 23 ++++------------------- 9 files changed, 31 insertions(+), 37 deletions(-) create mode 100644 wled00/data/update.htm diff --git a/wled00/WS2812FX.h b/wled00/WS2812FX.h index ce65547c..d7ff5b46 100644 --- a/wled00/WS2812FX.h +++ b/wled00/WS2812FX.h @@ -301,11 +301,10 @@ class WS2812FX { colorOrder = 0; paletteFade = 0; paletteBlend = 0; - ablMilliampsMax = 750; + ablMilliampsMax = 850; currentMilliamps = 0; - _locked = NULL; + _locked = nullptr; _modeUsesLock = false; - _cronixieDigits = new byte[6]; bus = new NeoPixelWrapper(); RESET_RUNTIME; } @@ -499,7 +498,7 @@ class WS2812FX { _triggered; byte* _locked; - byte* _cronixieDigits; + byte _cronixieDigits[6]; mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element diff --git a/wled00/data/update.htm b/wled00/data/update.htm new file mode 100644 index 00000000..9afd29c2 --- /dev/null +++ b/wled00/data/update.htm @@ -0,0 +1,4 @@ + +WLED Message + +

WLED Software Update

Installed version: 0.8.4-dev
Download the latest binary:

\ No newline at end of file diff --git a/wled00/html_other.h b/wled00/html_other.h index 4c776f6c..75b13c1e 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -4,7 +4,7 @@ //USER HTML HERE (/u subpage) const char PAGE_usermod[] PROGMEM = R"=====( -There is no usermod installed or it doesn't specify a custom web page.)====="; +No usermod installed or it doesn't specify a custom web page.)====="; //server message @@ -12,15 +12,21 @@ const char PAGE_msg[] PROGMEM = R"=====( WLED Message -%CSS%.bt{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}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%%;margin:0;background-attachment:fixed} +%CSS%.bt{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}

%MSG%)====="; +//firmware update page +const char PAGE_update[] PROGMEM = R"=====( +WLED Message +%CSS%.bt{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}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%%} +

WLED Software Update

Installed version: 0.8.4-dev
Download the latest binary:

)====="; + + //new user welcome page #ifndef WLED_DISABLE_MOBILE_UI const char PAGE_welcome[] PROGMEM = R"=====( - -WLED Welcome! +WLED Welcome! %CSS%body{font-family:var(--cFn),sans-serif;text-align:center;background:linear-gradient(var(--bCol),black);margin:0;background-attachment: fixed;color: var(--tCol);}svg {fill: var(--dCol);} diff --git a/wled00/wled00.ino b/wled00/wled00.ino index e76a444b..def802a6 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -89,7 +89,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1903091 +#define VERSION 1903092 char versionString[] = "0.8.4-dev"; @@ -122,8 +122,6 @@ bool recoveryAPDisabled = false; //never open AP (not recommended) IPAddress staticIP(0, 0, 0, 0); //static IP of ESP IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home networks -IPAddress staticDNS(8, 8, 8, 8); //only for NTP, google DNS server - //LED CONFIG uint16_t ledCount = 30; //overcurrent prevented by ABL @@ -533,6 +531,7 @@ void loop() { if (aOtaEnabled) ArduinoOTA.handle(); #endif handleNightlight(); + yield(); if (!onlyAP) { handleHue(); handleBlynk(); diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 1180c437..61b978ab 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -6,7 +6,7 @@ void XML_response(AsyncWebServerRequest *request, bool includeTheme) { olen = 0; - oappend(""); + oappend(""); oappendi((nightlightActive && nightlightFade) ? briT : bri); oappend(""); diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 9c95ae97..639eb427 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -309,14 +309,14 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) //helper to get int value at a position in string -int getNumVal(String* req, uint16_t pos) +int getNumVal(const String* req, uint16_t pos) { return req->substring(pos+3).toInt(); } //helper to get int value at a position in string -bool updateVal(String* req, const char* key, byte* val, byte minv=0, byte maxv=255) +bool updateVal(const String* req, const char* key, byte* val, byte minv=0, byte maxv=255) { int pos = req->indexOf(key); if (pos < 1) return false; @@ -346,7 +346,7 @@ bool updateVal(String* req, const char* key, byte* val, byte minv=0, byte maxv=2 //HTTP API request parser -bool handleSet(AsyncWebServerRequest *request, String req) +bool handleSet(AsyncWebServerRequest *request, const String& req) { if (!(req.indexOf("win") >= 0)) return false; diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 514ea934..05741bdf 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -175,7 +175,7 @@ void initCon() if (staticIP[0] != 0) { - WiFi.config(staticIP, staticGateway, staticSubnet, staticDNS); + WiFi.config(staticIP, staticGateway, staticSubnet, IPAddress(8,8,8,8)); } else { WiFi.config(0U, 0U, 0U); diff --git a/wled00/wled16_blynk.ino b/wled00/wled16_blynk.ino index e6eb0365..a430bedc 100644 --- a/wled00/wled16_blynk.ino +++ b/wled00/wled16_blynk.ino @@ -60,7 +60,8 @@ BLYNK_WRITE(V2) BLYNK_WRITE(V3) { - handleSet(nullptr, (param.asInt()>0)?"win&T=1&IN":"win&T=0&IN");//power + bool on = (param.asInt()>0); + if (!on != !bri) {toggleOnOff(); colorUpdated(9);} } BLYNK_WRITE(V4) @@ -83,7 +84,7 @@ BLYNK_WRITE(V6) BLYNK_WRITE(V7) { - handleSet(nullptr, (param.asInt()>0)?"win&ND&IN":"win&NL=0&IN");//nl + nightlightActive = (param.asInt()>0); } BLYNK_WRITE(V8) diff --git a/wled00/wled18_server.ino b/wled00/wled18_server.ino index f569bb70..58667001 100644 --- a/wled00/wled18_server.ino +++ b/wled00/wled18_server.ino @@ -90,19 +90,6 @@ void initServer() server.on("/freeheap", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", (String)ESP.getFreeHeap()); }); - - server.on("/power", HTTP_GET, [](AsyncWebServerRequest *request){ - String val = ""; - if (strip.currentMilliamps == 0) - { - val = "Power calculation disabled"; - } else - { - val += (String)strip.currentMilliamps; - val += "mA currently"; - } - serveMessage(request, 200, val, "This is just an estimate (does not account for factors like wire resistance). It is NOT a measurement!", 254); - }); //*******END*******/ server.on("/u", HTTP_GET, [](AsyncWebServerRequest *request){ @@ -127,10 +114,9 @@ void initServer() //init ota page #ifndef WLED_DISABLE_OTA server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){ - serveMessage(request, 200, "WLED Software Update", "Installed version: " + String(versionString) + "
Download the latest binary: " - "" - "
" - "
", 254); + olen = 0; + getCSSColors(); + request->send_P(200, "text/html", PAGE_update, msgProcessor); }); server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){ @@ -251,8 +237,7 @@ String msgProcessor(const String& var) { if (var == "CSS") return String(obuf); if (var == "MSG") { - String messageBody = ""; - messageBody += messageHead; + String messageBody = messageHead; messageBody += ""; messageBody += messageSub; uint32_t optt = optionType;