mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-29 22:26:37 +00:00
Memory optimization
This commit is contained in:
parent
4acc2d0ac8
commit
99e12e46c7
@ -206,7 +206,7 @@ board_build.f_cpu = 160000000L ; set frequency to 160MHz
|
|||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
; -- TFT_eSPI build options ------------------------
|
; -- TFT_eSPI build options ------------------------
|
||||||
-D MQTT_MAX_PACKET_SIZE=512 ; longer PubSubClient messages
|
-D MQTT_MAX_PACKET_SIZE=1024 ; longer PubSubClient messages
|
||||||
-D TFT_ROTATION=${lcd.TFT_ROTATION}
|
-D TFT_ROTATION=${lcd.TFT_ROTATION}
|
||||||
-D TFT_WIDTH=${lcd.TFT_WIDTH}
|
-D TFT_WIDTH=${lcd.TFT_WIDTH}
|
||||||
-D TFT_HEIGHT=${lcd.TFT_HEIGHT}
|
-D TFT_HEIGHT=${lcd.TFT_HEIGHT}
|
||||||
@ -240,7 +240,7 @@ board_build.ldscript = eagle.flash.4m2m.ld ; 2Mb Spiffs
|
|||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
; -- TFT_eSPI build options ------------------------
|
; -- TFT_eSPI build options ------------------------
|
||||||
-D MQTT_MAX_PACKET_SIZE=512 ; longer PubSubClient messages
|
-D MQTT_MAX_PACKET_SIZE=1024 ; longer PubSubClient messages
|
||||||
-D TFT_ROTATION=${lcd.TFT_ROTATION}
|
-D TFT_ROTATION=${lcd.TFT_ROTATION}
|
||||||
-D TFT_WIDTH=${lcd.TFT_WIDTH}
|
-D TFT_WIDTH=${lcd.TFT_WIDTH}
|
||||||
-D TFT_HEIGHT=${lcd.TFT_HEIGHT}
|
-D TFT_HEIGHT=${lcd.TFT_HEIGHT}
|
||||||
|
@ -1649,7 +1649,7 @@ void haspLoadPage(String pages)
|
|||||||
|
|
||||||
File file = SPIFFS.open(pages, "r");
|
File file = SPIFFS.open(pages, "r");
|
||||||
// ReadBufferingStream bufferingStream(file, 256);
|
// ReadBufferingStream bufferingStream(file, 256);
|
||||||
DynamicJsonDocument config(254);
|
DynamicJsonDocument config(256);
|
||||||
|
|
||||||
uint8_t savedPage = current_page;
|
uint8_t savedPage = current_page;
|
||||||
while(deserializeJson(config, file) == DeserializationError::Ok) {
|
while(deserializeJson(config, file) == DeserializationError::Ok) {
|
||||||
|
@ -219,10 +219,10 @@ void dispatchJson(char * payload)
|
|||||||
void dispatchJsonl(char * strPayload)
|
void dispatchJsonl(char * strPayload)
|
||||||
{
|
{
|
||||||
Serial.println("JSONL\n");
|
Serial.println("JSONL\n");
|
||||||
DynamicJsonDocument config(254);
|
DynamicJsonDocument config(256);
|
||||||
|
|
||||||
String output((char *)0);
|
String output((char *)0);
|
||||||
output.reserve(1500);
|
output.reserve(MQTT_MAX_PACKET_SIZE+ 256);
|
||||||
|
|
||||||
StringStream stream((String &)output);
|
StringStream stream((String &)output);
|
||||||
stream.print(strPayload);
|
stream.print(strPayload);
|
||||||
|
@ -31,6 +31,7 @@ File fsUploadFile;
|
|||||||
char httpUser[32] = "";
|
char httpUser[32] = "";
|
||||||
char httpPassword[32] = "";
|
char httpPassword[32] = "";
|
||||||
HTTPUpload * upload;
|
HTTPUpload * upload;
|
||||||
|
#define HTTP_PAGE_SIZE (6 * 256)
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
@ -173,7 +174,7 @@ void webHandleRoot()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += String(F("<h1>"));
|
httpMessage += String(F("<h1>"));
|
||||||
httpMessage += String(nodename);
|
httpMessage += String(nodename);
|
||||||
@ -231,7 +232,7 @@ void webHandleScreenshot()
|
|||||||
|
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += F("<p class='c'><img id='bmp' src='?q=0'></p>");
|
httpMessage += F("<p class='c'><img id='bmp' src='?q=0'></p>");
|
||||||
httpMessage += F("<p><form method='get' onsubmit=\"var timestamp = new Date().getTime();var ");
|
httpMessage += F("<p><form method='get' onsubmit=\"var timestamp = new Date().getTime();var ");
|
||||||
@ -254,7 +255,7 @@ void webHandleAbout()
|
|||||||
|
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += F("<p><h3>HASP OpenHardware edition</h3>Copyright© 2020 Francis Van Roie ");
|
httpMessage += F("<p><h3>HASP OpenHardware edition</h3>Copyright© 2020 Francis Van Roie ");
|
||||||
httpMessage += FPSTR(MIT_LICENSE);
|
httpMessage += FPSTR(MIT_LICENSE);
|
||||||
@ -299,7 +300,7 @@ void webHandleInfo()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
/* HASP Stats */
|
/* HASP Stats */
|
||||||
httpMessage += F("<hr><b>HASP Version: </b>");
|
httpMessage += F("<hr><b>HASP Version: </b>");
|
||||||
@ -667,7 +668,7 @@ void webHandleConfig()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += F("<hr>");
|
httpMessage += F("<hr>");
|
||||||
httpMessage +=
|
httpMessage +=
|
||||||
@ -713,7 +714,7 @@ void webHandleMqttConfig()
|
|||||||
|
|
||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += String(F("<form method='POST' action='/config'>"));
|
httpMessage += String(F("<form method='POST' action='/config'>"));
|
||||||
httpMessage += F("<b>HASP Node Name</b> <i><small>(required. lowercase letters, numbers, and _ only)</small>"
|
httpMessage += F("<b>HASP Node Name</b> <i><small>(required. lowercase letters, numbers, and _ only)</small>"
|
||||||
@ -759,7 +760,7 @@ void webHandleGuiConfig()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += String(F("<form method='POST' action='/config'>"));
|
httpMessage += String(F("<form method='POST' action='/config'>"));
|
||||||
|
|
||||||
@ -829,7 +830,7 @@ void webHandleWifiConfig()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += String(F("<form method='POST' action='/config'>"));
|
httpMessage += String(F("<form method='POST' action='/config'>"));
|
||||||
httpMessage += String(F("<b>WiFi SSID</b> <i><small>(required)</small></i><input id='ssid' required "
|
httpMessage += String(F("<b>WiFi SSID</b> <i><small>(required)</small></i><input id='ssid' required "
|
||||||
@ -866,7 +867,7 @@ void webHandleHttpConfig()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += String(F("<form method='POST' action='/config'>"));
|
httpMessage += String(F("<form method='POST' action='/config'>"));
|
||||||
httpMessage += String(F("<b>Web Username</b> <i><small>(optional)</small></i><input id='user' "
|
httpMessage += String(F("<b>Web Username</b> <i><small>(optional)</small></i><input id='user' "
|
||||||
@ -900,7 +901,7 @@ void webHandleDebugConfig()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += String(F("<form method='POST' action='/config'>"));
|
httpMessage += String(F("<form method='POST' action='/config'>"));
|
||||||
httpMessage += String(F("<p><b>Telemetry Period</b> <input id='teleperiod' required "
|
httpMessage += String(F("<p><b>Telemetry Period</b> <input id='teleperiod' required "
|
||||||
@ -929,7 +930,7 @@ void webHandleHaspConfig()
|
|||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
httpMessage += F("<p><form action='/edit' method='post' enctype='multipart/form-data'><input type='file' "
|
httpMessage += F("<p><form action='/edit' method='post' enctype='multipart/form-data'><input type='file' "
|
||||||
"name='filename' accept='.jsonl,.zi'>");
|
"name='filename' accept='.jsonl,.zi'>");
|
||||||
@ -1026,7 +1027,7 @@ void httpHandleNotFound()
|
|||||||
debugPrintln(String(F("HTTP: Sending 404 to client connected from: ")) + webServer.client().remoteIP().toString());
|
debugPrintln(String(F("HTTP: Sending 404 to client connected from: ")) + webServer.client().remoteIP().toString());
|
||||||
|
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
httpMessage += F("File Not Found\n\nURI: ");
|
httpMessage += F("File Not Found\n\nURI: ");
|
||||||
httpMessage += webServer.uri();
|
httpMessage += webServer.uri();
|
||||||
httpMessage += F("\nMethod: ");
|
httpMessage += F("\nMethod: ");
|
||||||
@ -1062,7 +1063,7 @@ void httpHandleEspFirmware()
|
|||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
httpMessage += String(F("<h1>"));
|
httpMessage += String(F("<h1>"));
|
||||||
httpMessage += String(haspGetNodename());
|
httpMessage += String(haspGetNodename());
|
||||||
httpMessage += String(F(" ESP update</h1><br/>Updating ESP firmware from: "));
|
httpMessage += String(F(" ESP update</h1><br/>Updating ESP firmware from: "));
|
||||||
@ -1086,7 +1087,7 @@ void httpHandleResetConfig()
|
|||||||
String nodename = haspGetNodename();
|
String nodename = haspGetNodename();
|
||||||
// char buffer[128];
|
// char buffer[128];
|
||||||
String httpMessage((char *)0);
|
String httpMessage((char *)0);
|
||||||
httpMessage.reserve(1500);
|
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||||
|
|
||||||
if(resetConfirmed) { // User has confirmed, so reset everything
|
if(resetConfirmed) { // User has confirmed, so reset everything
|
||||||
httpMessage += F("<h1>");
|
httpMessage += F("<h1>");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user