Small memory improvements

This commit is contained in:
cschwinne 2019-03-09 21:41:23 +01:00
parent b9c27ed324
commit b72e6f16ca
9 changed files with 31 additions and 37 deletions

View File

@ -301,11 +301,10 @@ class WS2812FX {
colorOrder = 0; colorOrder = 0;
paletteFade = 0; paletteFade = 0;
paletteBlend = 0; paletteBlend = 0;
ablMilliampsMax = 750; ablMilliampsMax = 850;
currentMilliamps = 0; currentMilliamps = 0;
_locked = NULL; _locked = nullptr;
_modeUsesLock = false; _modeUsesLock = false;
_cronixieDigits = new byte[6];
bus = new NeoPixelWrapper(); bus = new NeoPixelWrapper();
RESET_RUNTIME; RESET_RUNTIME;
} }
@ -499,7 +498,7 @@ class WS2812FX {
_triggered; _triggered;
byte* _locked; byte* _locked;
byte* _cronixieDigits; byte _cronixieDigits[6];
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element

4
wled00/data/update.htm Normal file
View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'><title>WLED Message</title><script>function B(){window.history.back()}</script>
<style>:root{--aCol:#D9B310;--bCol:#0B3C5D;--cCol:#1D2731;--dCol:#328CC1;--sCol:#000;--tCol:#328CC1;--cFn:Verdana;}.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%}</style></head>
<body><h2>WLED Software Update</h2>Installed version: 0.8.4-dev<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>

View File

@ -4,7 +4,7 @@
//USER HTML HERE (/u subpage) //USER HTML HERE (/u subpage)
const char PAGE_usermod[] PROGMEM = R"=====(<!DOCTYPE html> const char PAGE_usermod[] PROGMEM = R"=====(<!DOCTYPE html>
<html><body>There is no usermod installed or it doesn't specify a custom web page.</body></html>)====="; <html><body>No usermod installed or it doesn't specify a custom web page.</body></html>)=====";
//server message //server message
@ -12,15 +12,21 @@ const char PAGE_msg[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'> <html><head><meta content='width=device-width' name='viewport'>
<title>WLED Message</title> <title>WLED Message</title>
<script>function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href="/";}</script> <script>function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href="/";}</script>
%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}</style></head> %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}</style></head>
<body><h2>%MSG%</body></html>)====="; <body><h2>%MSG%</body></html>)=====";
//firmware update page
const char PAGE_update[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'><title>WLED Message</title><script>function B(){window.history.back()}</script>
%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%%}</style></head>
<body><h2>WLED Software Update</h2>Installed version: 0.8.4-dev<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>)=====";
//new user welcome page //new user welcome page
#ifndef WLED_DISABLE_MOBILE_UI #ifndef WLED_DISABLE_MOBILE_UI
const char PAGE_welcome[] PROGMEM = R"=====(<!DOCTYPE html> const char PAGE_welcome[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'> <html><head><meta content='width=device-width' name='viewport'><title>WLED Welcome!</title>
<title>WLED Welcome!</title>
%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);} %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);}
</style></head> </style></head>
<body> <body>

View File

@ -89,7 +89,7 @@
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 1903091 #define VERSION 1903092
char versionString[] = "0.8.4-dev"; 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 staticIP(0, 0, 0, 0); //static IP of ESP
IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP
IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home networks 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 //LED CONFIG
uint16_t ledCount = 30; //overcurrent prevented by ABL uint16_t ledCount = 30; //overcurrent prevented by ABL
@ -533,6 +531,7 @@ void loop() {
if (aOtaEnabled) ArduinoOTA.handle(); if (aOtaEnabled) ArduinoOTA.handle();
#endif #endif
handleNightlight(); handleNightlight();
yield();
if (!onlyAP) { if (!onlyAP) {
handleHue(); handleHue();
handleBlynk(); handleBlynk();

View File

@ -6,7 +6,7 @@
void XML_response(AsyncWebServerRequest *request, bool includeTheme) void XML_response(AsyncWebServerRequest *request, bool includeTheme)
{ {
olen = 0; olen = 0;
oappend("<?xml version = \"1.0\" ?><vs><ac>"); oappend("<?xml version=\"1.0\" ?><vs><ac>");
oappendi((nightlightActive && nightlightFade) ? briT : bri); oappendi((nightlightActive && nightlightFade) ? briT : bri);
oappend("</ac>"); oappend("</ac>");

View File

@ -309,14 +309,14 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
//helper to get int value at a position in string //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(); return req->substring(pos+3).toInt();
} }
//helper to get int value at a position in string //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); int pos = req->indexOf(key);
if (pos < 1) return false; 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 //HTTP API request parser
bool handleSet(AsyncWebServerRequest *request, String req) bool handleSet(AsyncWebServerRequest *request, const String& req)
{ {
if (!(req.indexOf("win") >= 0)) return false; if (!(req.indexOf("win") >= 0)) return false;

View File

@ -175,7 +175,7 @@ void initCon()
if (staticIP[0] != 0) if (staticIP[0] != 0)
{ {
WiFi.config(staticIP, staticGateway, staticSubnet, staticDNS); WiFi.config(staticIP, staticGateway, staticSubnet, IPAddress(8,8,8,8));
} else } else
{ {
WiFi.config(0U, 0U, 0U); WiFi.config(0U, 0U, 0U);

View File

@ -60,7 +60,8 @@ BLYNK_WRITE(V2)
BLYNK_WRITE(V3) 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) BLYNK_WRITE(V4)
@ -83,7 +84,7 @@ BLYNK_WRITE(V6)
BLYNK_WRITE(V7) BLYNK_WRITE(V7)
{ {
handleSet(nullptr, (param.asInt()>0)?"win&ND&IN":"win&NL=0&IN");//nl nightlightActive = (param.asInt()>0);
} }
BLYNK_WRITE(V8) BLYNK_WRITE(V8)

View File

@ -90,19 +90,6 @@ void initServer()
server.on("/freeheap", HTTP_GET, [](AsyncWebServerRequest *request){ server.on("/freeheap", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/plain", (String)ESP.getFreeHeap()); 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*******/ //*******END*******/
server.on("/u", HTTP_GET, [](AsyncWebServerRequest *request){ server.on("/u", HTTP_GET, [](AsyncWebServerRequest *request){
@ -127,10 +114,9 @@ void initServer()
//init ota page //init ota page
#ifndef WLED_DISABLE_OTA #ifndef WLED_DISABLE_OTA
server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){ server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 200, "WLED Software Update", "Installed version: " + String(versionString) + "<br>Download the latest binary: " olen = 0;
"<a href=\"https://github.com/Aircoookie/WLED/releases\"><img src=\"https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square\"></a>" getCSSColors();
"<br><form method='POST' action='/update' enctype='multipart/form-data'>" request->send_P(200, "text/html", PAGE_update, msgProcessor);
"<input type='file' class=\"bt\" name='update' required><br><input type='submit' class=\"bt\" value='Update!'></form>", 254);
}); });
server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){ server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){
@ -251,8 +237,7 @@ String msgProcessor(const String& var)
{ {
if (var == "CSS") return String(obuf); if (var == "CSS") return String(obuf);
if (var == "MSG") { if (var == "MSG") {
String messageBody = ""; String messageBody = messageHead;
messageBody += messageHead;
messageBody += "</h2>"; messageBody += "</h2>";
messageBody += messageSub; messageBody += messageSub;
uint32_t optt = optionType; uint32_t optt = optionType;