Memory optimization

This commit is contained in:
fvanroie 2020-03-10 01:50:48 +01:00
parent 4acc2d0ac8
commit 99e12e46c7
4 changed files with 20 additions and 19 deletions

View File

@ -206,7 +206,7 @@ board_build.f_cpu = 160000000L ; set frequency to 160MHz
build_flags =
${env.build_flags}
; -- 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_WIDTH=${lcd.TFT_WIDTH}
-D TFT_HEIGHT=${lcd.TFT_HEIGHT}
@ -240,7 +240,7 @@ board_build.ldscript = eagle.flash.4m2m.ld ; 2Mb Spiffs
build_flags =
${env.build_flags}
; -- 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_WIDTH=${lcd.TFT_WIDTH}
-D TFT_HEIGHT=${lcd.TFT_HEIGHT}

View File

@ -1649,7 +1649,7 @@ void haspLoadPage(String pages)
File file = SPIFFS.open(pages, "r");
// ReadBufferingStream bufferingStream(file, 256);
DynamicJsonDocument config(254);
DynamicJsonDocument config(256);
uint8_t savedPage = current_page;
while(deserializeJson(config, file) == DeserializationError::Ok) {

View File

@ -219,10 +219,10 @@ void dispatchJson(char * payload)
void dispatchJsonl(char * strPayload)
{
Serial.println("JSONL\n");
DynamicJsonDocument config(254);
DynamicJsonDocument config(256);
String output((char *)0);
output.reserve(1500);
output.reserve(MQTT_MAX_PACKET_SIZE+ 256);
StringStream stream((String &)output);
stream.print(strPayload);

View File

@ -31,6 +31,7 @@ File fsUploadFile;
char httpUser[32] = "";
char httpPassword[32] = "";
HTTPUpload * upload;
#define HTTP_PAGE_SIZE (6 * 256)
#if defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266WebServer.h>
@ -173,7 +174,7 @@ void webHandleRoot()
// char buffer[128];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<h1>"));
httpMessage += String(nodename);
@ -231,7 +232,7 @@ void webHandleScreenshot()
String nodename = haspGetNodename();
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><form method='get' onsubmit=\"var timestamp = new Date().getTime();var ");
@ -254,7 +255,7 @@ void webHandleAbout()
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("<p><h3>HASP OpenHardware edition</h3>Copyright&copy; 2020 Francis Van Roie ");
httpMessage += FPSTR(MIT_LICENSE);
@ -299,7 +300,7 @@ void webHandleInfo()
// char buffer[128];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
/* HASP Stats */
httpMessage += F("<hr><b>HASP Version: </b>");
@ -667,7 +668,7 @@ void webHandleConfig()
// char buffer[128];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("<hr>");
httpMessage +=
@ -713,7 +714,7 @@ void webHandleMqttConfig()
// char buffer[128];
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<form method='POST' action='/config'>"));
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];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<form method='POST' action='/config'>"));
@ -829,7 +830,7 @@ void webHandleWifiConfig()
// char buffer[128];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<form method='POST' action='/config'>"));
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];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<form method='POST' action='/config'>"));
httpMessage += String(F("<b>Web Username</b> <i><small>(optional)</small></i><input id='user' "
@ -900,7 +901,7 @@ void webHandleDebugConfig()
// char buffer[128];
String nodename = haspGetNodename();
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<form method='POST' action='/config'>"));
httpMessage += String(F("<p><b>Telemetry Period</b> <input id='teleperiod' required "
@ -929,7 +930,7 @@ void webHandleHaspConfig()
// char buffer[128];
String nodename = haspGetNodename();
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' "
"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());
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("File Not Found\n\nURI: ");
httpMessage += webServer.uri();
httpMessage += F("\nMethod: ");
@ -1062,7 +1063,7 @@ void httpHandleEspFirmware()
String nodename = haspGetNodename();
// char buffer[128];
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += String(F("<h1>"));
httpMessage += String(haspGetNodename());
httpMessage += String(F(" ESP update</h1><br/>Updating ESP firmware from: "));
@ -1086,7 +1087,7 @@ void httpHandleResetConfig()
String nodename = haspGetNodename();
// char buffer[128];
String httpMessage((char *)0);
httpMessage.reserve(1500);
httpMessage.reserve(HTTP_PAGE_SIZE);
if(resetConfirmed) { // User has confirmed, so reset everything
httpMessage += F("<h1>");