Memory optimization

This commit is contained in:
fvanroie 2020-02-26 21:38:50 +01:00
parent 0ba976bcde
commit e4864d4d5d
2 changed files with 39 additions and 35 deletions

View File

@ -64,8 +64,8 @@ upload_speed = 921600
; -- Shared library dependencies in all environments ; -- Shared library dependencies in all environments
lib_deps = lib_deps =
;lvgl@^7.0.0 ; Not in library yet ;lvgl@^7.0.0 ; Not in library yet
;TFT_eSPI@^2.1.3 ; Tft SPI drivers TFT_eSPI@^2.1.3 ; Tft SPI drivers
TFT_eSPI@^1.4.20 ; Tft SPI drivers ;TFT_eSPI@^1.4.20 ; Tft SPI drivers
PubSubClient@^2.7.0 ; MQTT client PubSubClient@^2.7.0 ; MQTT client
ArduinoJson@^6.14.1,>6.14.0 ; needs at least 6.14.1 ArduinoJson@^6.14.1,>6.14.0 ; needs at least 6.14.1
Syslog@^2.0.0 Syslog@^2.0.0
@ -80,7 +80,7 @@ build_flags =
-D SPIFFS_TEMPORAL_FD_CACHE ; speedup opening recent files -D SPIFFS_TEMPORAL_FD_CACHE ; speedup opening recent files
-D ARDUINOJSON_DECODE_UNICODE=1 ; for utf-8 symbols -D ARDUINOJSON_DECODE_UNICODE=1 ; for utf-8 symbols
-D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments -D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments
-D HTTP_UPLOAD_BUFLEN=1436 ; lower ESP8266 upload buffer -D HTTP_UPLOAD_BUFLEN=1024 ; lower http upload buffer
-I include ; include lv_conf.h and hasp_conf.h -I include ; include lv_conf.h and hasp_conf.h
${override.build_flags} ${override.build_flags}

View File

@ -93,14 +93,14 @@ static const char * btnm_map2[] = {"0", "1", "\n", "2", "3", "\n", "4", "5",
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
static lv_obj_t * pages[4]; static lv_obj_t * pages[4];
static lv_font_t * haspFonts[4]; // static lv_font_t * haspFonts[4];
static lv_style_t labelStyles[4]; // static lv_style_t labelStyles[4];
static lv_style_t rollerStyles[4]; // static lv_style_t rollerStyles[4];
#else #else
static lv_obj_t * pages[12]; static lv_obj_t * pages[12];
static lv_font_t * haspFonts[8]; // static lv_font_t * haspFonts[8];
static lv_style_t labelStyles[8]; // static lv_style_t labelStyles[8];
static lv_style_t rollerStyles[8]; // static lv_style_t rollerStyles[8];
#endif #endif
uint16_t current_page = 0; uint16_t current_page = 0;
// uint16_t current_style = 0; // uint16_t current_style = 0;
@ -925,6 +925,7 @@ void haspSetup(JsonObject settings)
// lv_obj_set_size(pages[0], hres, vres); // lv_obj_set_size(pages[0], hres, vres);
} }
/*
if(lv_zifont_font_init(&haspFonts[0], "/fonts/HMI FrankRuhlLibre 24.zi", 24) != 0) { if(lv_zifont_font_init(&haspFonts[0], "/fonts/HMI FrankRuhlLibre 24.zi", 24) != 0) {
errorPrintln(String(F("HASP: %sFailed to set the custom font to 0"))); errorPrintln(String(F("HASP: %sFailed to set the custom font to 0")));
defaultFont = NULL; // Use default font defaultFont = NULL; // Use default font
@ -939,10 +940,11 @@ void haspSetup(JsonObject settings)
} }
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
lv_style_copy(&labelStyles[i], &lv_style_pretty_color); //lv_style_copy(&labelStyles[i], &lv_style_pretty_color);
labelStyles[i].text.font = haspFonts[i]; labelStyles[i].text.font = haspFonts[i];
labelStyles[i].text.color = LV_COLOR_BLUE; labelStyles[i].text.color = LV_COLOR_BLUE;
} }
*/
/* /*
lv_obj_t * obj; lv_obj_t * obj;
@ -1332,10 +1334,10 @@ void haspNewObject(const JsonObject & config)
if(config[F("txt")]) { if(config[F("txt")]) {
lv_label_set_text(obj, config[F("txt")].as<String>().c_str()); lv_label_set_text(obj, config[F("txt")].as<String>().c_str());
} }
if(styleid < sizeof labelStyles / sizeof *labelStyles) { /*if(styleid < sizeof labelStyles / sizeof *labelStyles) {
debugPrintln(String(F("HASP: Styleid set to ")) + styleid); debugPrintln(String(F("HASP: Styleid set to ")) + styleid);
// lv_label_set_style(obj, LV_LABEL_STYLE_MAIN, &labelStyles[styleid]); lv_label_set_style(obj, LV_LABEL_STYLE_MAIN, &labelStyles[styleid]);
} }*/
/* click area padding */ /* click area padding */
uint8_t padh = config[F("padh")].as<uint8_t>(); uint8_t padh = config[F("padh")].as<uint8_t>();
uint8_t padv = config[F("padv")].as<uint8_t>(); uint8_t padv = config[F("padv")].as<uint8_t>();
@ -1482,15 +1484,17 @@ void haspNewObject(const JsonObject & config)
/** testing end **/ /** testing end **/
char msg[127]; char msg[127];
sprintf_P(msg, PSTR("HASP: Created object p[%u].b[%u]"), pageid, temp); lv_obj_type_t list;
lv_obj_get_type(obj, &list);
sprintf_P(msg, PSTR("HASP: * Created %s object p[%u].b[%u]"), list.type[0], pageid, temp);
debugPrintln(msg); debugPrintln(msg);
/* Double-check */ /* Double-check */
lv_obj_t * test = FindObjFromId(pageid, (uint8_t)temp); lv_obj_t * test = FindObjFromId(pageid, (uint8_t)temp);
if(test == obj) { if(test != obj) {
debugPrintln(F("Objects match!"));
} else {
errorPrintln(F("HASP: %sObjects DO NOT match!")); errorPrintln(F("HASP: %sObjects DO NOT match!"));
} else {
// debugPrintln(F("Objects match!"));
} }
} }
@ -1517,8 +1521,8 @@ void haspLoadPage(String pages)
uint8_t savedPage = current_page; uint8_t savedPage = current_page;
while(deserializeJson(config, file) == DeserializationError::Ok) { while(deserializeJson(config, file) == DeserializationError::Ok) {
serializeJson(config, Serial); // serializeJson(config, Serial);
Serial.println(); // Serial.println();
haspNewObject(config.as<JsonObject>()); haspNewObject(config.as<JsonObject>());
} }
current_page = savedPage; current_page = savedPage;