diff --git a/include/lv_conf.h b/include/lv_conf.h index 5c254173..8ee07c81 100644 --- a/include/lv_conf.h +++ b/include/lv_conf.h @@ -338,7 +338,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ * LV_FONT_DECLARE(my_font_2) */ -#define LV_FONT_CUSTOM_DECLARE static lv_font_t *defaultFont; +//#define LV_FONT_CUSTOM_DECLARE static lv_font_t *defaultFont; /*Always set a default font from the built-in fonts*/ #define LV_FONT_DEFAULT &lv_font_unscii_8 diff --git a/lib/lv_fs_if/lv_fs_spiffs.cpp b/lib/lv_fs_if/lv_fs_spiffs.cpp index c3670293..9546eea0 100644 --- a/lib/lv_fs_if/lv_fs_spiffs.cpp +++ b/lib/lv_fs_if/lv_fs_spiffs.cpp @@ -174,7 +174,7 @@ static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p) // File file = *(File *)(file_p); lv_spiffs_file_t * file = (lv_spiffs_file_t *)file_p; /*Convert type*/ - char * msg; + char * msg = nullptr; sprintf(msg, "Closing: %s", file->name()); Serial.println(msg); Serial.flush(); @@ -196,9 +196,9 @@ static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p) static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br) { lv_spiffs_file_t * file = (lv_spiffs_file_t *)file_p; /*Convert type*/ - // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); + // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); - char * msg; + char * msg = nullptr; sprintf(msg, "Reading: %s", file->name()); Serial.println(msg); Serial.flush(); @@ -252,7 +252,7 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos) { lv_spiffs_file_t * file = (lv_spiffs_file_t *)file_p; /*Convert type*/ // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); - char * msg; + char * msg = nullptr; sprintf(msg, "Seeking: %s", file->name()); Serial.println(msg); Serial.flush(); @@ -274,8 +274,8 @@ static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos) static lv_fs_res_t fs_size(lv_fs_drv_t * drv, void * file_p, uint32_t * size_p) { lv_spiffs_file_t * file = (lv_spiffs_file_t *)file_p; /*Convert type*/ - // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); - char * msg; + // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); + char * msg = nullptr; sprintf(msg, "Filesize: %s", file->name()); Serial.println(msg); Serial.flush(); @@ -295,8 +295,8 @@ static lv_fs_res_t fs_size(lv_fs_drv_t * drv, void * file_p, uint32_t * size_p) static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) { lv_spiffs_file_t * file = (lv_spiffs_file_t *)file_p; /*Convert type*/ - // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); - char * msg; + // lv_spiffs_file_t file = *(lv_spiffs_file_t *)(file_p); + char * msg = nullptr; sprintf(msg, "Telling: %s", file->name()); Serial.println(msg); Serial.flush(); diff --git a/lib/lv_lib_zifont/lv_zifont.cpp b/lib/lv_lib_zifont/lv_zifont.cpp index f9efd64e..fbc0dda5 100644 --- a/lib/lv_lib_zifont/lv_zifont.cpp +++ b/lib/lv_lib_zifont/lv_zifont.cpp @@ -21,7 +21,7 @@ /********************** * TYPEDEFS **********************/ -typedef enum zifont_error_t { +enum zifont_error_t { ZIFONT_NO_ERROR, ZIFONT_ERROR_OUT_OF_MEMORY, ZIFONT_ERROR_OPENING_FILE, @@ -29,7 +29,7 @@ typedef enum zifont_error_t { ZIFONT_ERROR_UNKNOWN_HEADER }; -typedef enum zifont_codepage_t8_t { +enum zifont_codepage_t8_t { ASCII = 0x01, // GB2312 = 0x02, ISO_8859_1 = 0x03, @@ -124,7 +124,6 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size dsc = (lv_font_fmt_zifont_dsc_t *)(*font)->dsc; } if(dsc == NULL) return ZIFONT_ERROR_OUT_OF_MEMORY; - int error = 0; /* Initialize Last Glyph DSC */ dsc->last_glyph_dsc = (lv_zifont_char_t *)lv_mem_alloc(sizeof(lv_zifont_char_t)); @@ -236,7 +235,6 @@ int lv_zifont_font_init(lv_font_t ** font, const char * font_path, uint16_t size static const uint8_t * lv_font_get_bitmap_fmt_zifont(const lv_font_t * font, uint32_t unicode_letter) { lv_font_fmt_zifont_dsc_t * fdsc = (lv_font_fmt_zifont_dsc_t *)font->dsc; /* header data struct */ - int error = 0; uint32_t glyphID; char filename[32]; @@ -412,7 +410,6 @@ static bool lv_font_get_glyph_dsc_fmt_zifont(const lv_font_t * font, lv_font_gly // ulong startMillis = millis(); lv_font_fmt_zifont_dsc_t * fdsc = (lv_font_fmt_zifont_dsc_t *)font->dsc; /* header data struct */ uint16_t glyphID; - int error = 0; /* Only ascii characteres supported for now */ if(unicode_letter < 0x20) return false; @@ -476,8 +473,6 @@ static bool lv_font_get_glyph_dsc_fmt_zifont(const lv_font_t * font, lv_font_gly lastCharInfo = fdsc->ascii_glyph_dsc[glyphID]; } - uint8_t w = lastCharInfo.width + lastCharInfo.kerningL + lastCharInfo.kerningR; - /*cache glyph data*/ fdsc->last_glyph_id = glyphID; fdsc->last_glyph_dsc = &lastCharInfo; diff --git a/platformio.ini b/platformio.ini index 9e097501..78558e51 100644 --- a/platformio.ini +++ b/platformio.ini @@ -60,24 +60,26 @@ TFT_ROTATION = 0 ; 0=0, 1=90, 2=180 or 3=270 degree [env] framework = arduino -monitor_speed = 115200 +monitor_speed = 74880 upload_speed = 921600 ; -- Shared library dependencies in all environments lib_deps = ;lvgl@^7.0.0 ; Not in library yet - TFT_eSPI@^2.0.0 + TFT_eSPI@^2.1.2 PubSubClient@^2.7.0 ; MQTT client ArduinoJson@^6.14.1,>6.14.0 ; needs at least 6.14.1 Syslog@^2.0.0 + ; -- littlevgl config options ---------------------- build_flags = -Os ; Code Size Optimization - -w ; Suppress warnings + ;-w ; Suppress warnings -D LV_CONF_INCLUDE_SIMPLE -D SPIFFS_TEMPORAL_FD_CACHE ; speedup opening recent files -D ARDUINOJSON_DECODE_UNICODE=1 ; for utf-8 symbols -D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments + ;-D Pins_Arduino_h ; fix for D32 warnings -I include ; include lv_conf.h and hasp_conf.h ${override.build_flags} @@ -126,8 +128,8 @@ src_filter = +<*> +<../drivers/stm32f429_disco> [env:d1mini32-lolintft24] platform = espressif32 board = wemos_d1_mini32 -upload_port = COM6 ; Change to the correct port -monitor_port = COM6 ; Change to the correct port +upload_port = COM8 ; Change to the correct port +monitor_port = COM8 ; Change to the correct port board_build.partitions = default.csv build_flags = ${env.build_flags} @@ -190,10 +192,10 @@ upload_port = COM4 ; Change to the correct port monitor_port = COM4 ; Change to the correct port board_build.f_flash = 40000000L board_build.flash_mode = dout +board_build.ldscript = eagle.flash.4m3m.ld ; 3Mb Spiffs board_build.f_cpu = 160000000L ; set frequency to 160MHz build_flags = ${env.build_flags} - -Wl,-Teagle.flash.4m3m.ld ; -- TFT_eSPI build options ------------------------ -D MQTT_MAX_PACKET_SIZE=512 ; longer PubSubClient messages -D TFT_ROTATION=${lcd.TFT_ROTATION} @@ -224,9 +226,9 @@ monitor_port = COM5 upload_port = COM5 ; Change to the correct port board_build.f_flash = 40000000L board_build.flash_mode = dout +board_build.ldscript = eagle.flash.4m3m.ld ; 3Mb Spiffs build_flags = ${env.build_flags} - -Wl,-Teagle.flash.4m3m.ld ; -- TFT_eSPI build options ------------------------ -D MQTT_MAX_PACKET_SIZE=512 ; longer PubSubClient messages -D TFT_ROTATION=${lcd.TFT_ROTATION} diff --git a/src/hasp.cpp b/src/hasp.cpp index be7d4a69..ff392e38 100644 --- a/src/hasp.cpp +++ b/src/hasp.cpp @@ -63,6 +63,7 @@ void hasp_background(uint16_t pageid, uint16_t imageid); **********************/ static lv_style_t style_mbox_bg; /*Black bg. style with opacity*/ static lv_obj_t * kb; +static lv_font_t * defaultFont; #if LV_DEMO_WALLPAPER LV_IMG_DECLARE(img_bubble_pattern) @@ -425,12 +426,13 @@ bool haspGetObjAttribute(lv_obj_t * obj, String strAttr, std::string & strPayloa if(strAttr == F(".val")) { if(check_obj_type(list.type[0], LV_HASP_PRELOADER)) return false; - if(check_obj_type(list.type[0], LV_HASP_BUTTON)) + if(check_obj_type(list.type[0], LV_HASP_BUTTON)) { if(lv_btn_get_state(obj) == LV_BTN_STATE_TGL_PR || lv_btn_get_state(obj) == LV_BTN_STATE_TGL_REL) strPayload = "1"; // It's toggled else strPayload = "0"; // Normal btn has no toggle state + } if(check_obj_type(list.type[0], LV_HASP_SLIDER)) strPayload = String(lv_slider_get_value(obj)).c_str(); @@ -815,21 +817,21 @@ void haspFirstSetup(void) */ void haspSetup(JsonObject settings) { - char buffer[127]; - haspSetConfig(settings); -#ifdef LV_HASP_HOR_RES_MAX - lv_coord_t hres = LV_HASP_HOR_RES_MAX; -#else - lv_coord_t hres = lv_disp_get_hor_res(NULL); -#endif + /* + #ifdef LV_HASP_HOR_RES_MAX + lv_coord_t hres = LV_HASP_HOR_RES_MAX; + #else + lv_coord_t hres = lv_disp_get_hor_res(NULL); + #endif -#ifdef LV_HASP_VER_RES_MAX - lv_coord_t vres = LV_HASP_VER_RES_MAX; -#else - lv_coord_t vres = lv_disp_get_ver_res(NULL); -#endif + #ifdef LV_HASP_VER_RES_MAX + lv_coord_t vres = LV_HASP_VER_RES_MAX; + #else + lv_coord_t vres = lv_disp_get_ver_res(NULL); + #endif + */ // static lv_font_t * // my_font = (lv_font_t *)lv_mem_alloc(sizeof(lv_font_t)); @@ -1366,7 +1368,7 @@ void haspNewObject(const JsonObject & config) lv_slider_set_range(obj, min, max); lv_slider_set_value(obj, val, LV_ANIM_OFF); lv_obj_set_event_cb(obj, slider_event_handler); - bool knobin = config[F("knobin")].as() | true; + // bool knobin = config[F("knobin")].as() | true; // lv_slider_set_knob_in(obj, knobin); break; } @@ -1525,7 +1527,7 @@ bool haspGetConfig(const JsonObject & settings) settings[FPSTR(F_CONFIG_ZIFONT)] = haspZiFontPath; settings[FPSTR(F_CONFIG_PAGES)] = haspPagesPath; - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return true; @@ -1562,7 +1564,7 @@ bool haspSetConfig(const JsonObject & settings) haspThemeHue = settings[FPSTR(F_CONFIG_HUE)].as(); } - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return changed; diff --git a/src/hasp.h b/src/hasp.h index eb56deec..6379b74a 100644 --- a/src/hasp.h +++ b/src/hasp.h @@ -39,7 +39,7 @@ extern "C" { * TYPEDEFS **********************/ -typedef enum lv_hasp_obj_type_t { +enum lv_hasp_obj_type_t { LV_HASP_BUTTON = 10, LV_HASP_CHECKBOX = 11, LV_HASP_LABEL = 12, diff --git a/src/hasp_debug.cpp b/src/hasp_debug.cpp index a31844e7..c6b6ea49 100644 --- a/src/hasp_debug.cpp +++ b/src/hasp_debug.cpp @@ -46,7 +46,7 @@ Syslog syslog(syslogClient, debugSyslogHost.c_str(), debugSyslogPort, debugAppNa void debugSetup() { - Serial.begin(115200); /* prepare for possible serial debug */ + Serial.begin(74880); /* prepare for possible serial debug */ Serial.flush(); Serial.println(); Serial.println(); diff --git a/src/hasp_dispatch.cpp b/src/hasp_dispatch.cpp index 4b80e921..2569a6e7 100644 --- a/src/hasp_dispatch.cpp +++ b/src/hasp_dispatch.cpp @@ -111,8 +111,11 @@ void dispatchJson(char * payload) strPayload.remove(strPayload.length() - 2, 2); strPayload.concat("]"); }*/ + DynamicJsonDocument haspCommands(MQTT_MAX_PACKET_SIZE + 512); DeserializationError jsonError = deserializeJson(haspCommands, payload); + haspCommands.shrinkToFit(); + if(jsonError) { // Couldn't parse incoming JSON command errorPrintln(String(F("JSON: %sFailed to parse incoming JSON command with error: ")) + String(jsonError.c_str())); @@ -137,7 +140,7 @@ void dispatchReboot(bool saveConfig) debugStop(); delay(250); wifiStop(); - debugPrintln(F("CMND: Properly Rebooting the MCU now!")); + debugPrintln(F("STOP: Properly Rebooting the MCU now!")); debugPrintln(F("-------------------------------------")); ESP.restart(); delay(5000); diff --git a/src/hasp_gui.cpp b/src/hasp_gui.cpp index 85ffc184..059680db 100644 --- a/src/hasp_gui.cpp +++ b/src/hasp_gui.cpp @@ -483,7 +483,7 @@ void guiTakeScreenshot(const char * pFileName) pFileOut.write(bmpheader, sizeof(bmpheader)); if(pFileOut == NULL) { - printf(("[Display] error: %s cannot be opened", pFileName)); + printf("[Display] error: %s cannot be opened", pFileName); return; } @@ -493,7 +493,7 @@ void guiTakeScreenshot(const char * pFileName) guiSnapshot = 0; pFileOut.close(); - printf(("[Display] data flushed to %s", pFileName)); + printf("[Display] data flushed to %s", pFileName); } #if defined(ARDUINO_ARCH_ESP8266) diff --git a/src/hasp_hal.cpp b/src/hasp_hal.cpp index b2359d0c..d9b34372 100644 --- a/src/hasp_hal.cpp +++ b/src/hasp_hal.cpp @@ -96,4 +96,13 @@ uint8_t halGetHeapFragmentation() #else return ESP.getHeapFragmentation(); #endif +} + +size_t halGetMaxFreeBlock() +{ +#if defined(ARDUINO_ARCH_ESP32) + return ESP.getMaxAllocHeap(); +#else + return ESP.getMaxFreeBlockSize(); +#endif } \ No newline at end of file diff --git a/src/hasp_hal.h b/src/hasp_hal.h index 7b3bff5d..9f25777f 100644 --- a/src/hasp_hal.h +++ b/src/hasp_hal.h @@ -5,5 +5,6 @@ uint8_t halGetHeapFragmentation(void); String halGetResetInfo(void); +size_t halGetMaxFreeBlock(); #endif \ No newline at end of file diff --git a/src/hasp_http.cpp b/src/hasp_http.cpp index 05b05a48..72cfd548 100644 --- a/src/hasp_http.cpp +++ b/src/hasp_http.cpp @@ -148,7 +148,7 @@ void webHandleRoot() { if(!httpIsAuthenticated(F("root"))) return; - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -266,7 +266,7 @@ void webHandleInfo() { // http://plate01/ if(!httpIsAuthenticated(F("/info"))) return; - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -374,9 +374,7 @@ String urldecode(String str) { String encodedString = ""; char c; - char code0; - char code1; - for(int i = 0; i < str.length(); i++) { + for(unsigned int i = 0; i < str.length(); i++) { c = str.charAt(i); if(c == '+') { encodedString += ' '; @@ -606,7 +604,7 @@ void webHandleConfig() httpHandleReboot(); } - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -652,7 +650,7 @@ void webHandleMqttConfig() DynamicJsonDocument settings(256); mqttGetConfig(settings.to()); - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -696,7 +694,7 @@ void webHandleGuiConfig() DynamicJsonDocument settings(256); // guiGetConfig(settings.to()); - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -726,7 +724,7 @@ void webHandleWifiConfig() DynamicJsonDocument settings(256); wifiGetConfig(settings.to()); - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -762,7 +760,7 @@ void webHandleHttpConfig() DynamicJsonDocument settings(256); httpGetConfig(settings.to()); - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -797,7 +795,7 @@ void webHandleHaspConfig() DynamicJsonDocument settings(256); haspGetConfig(settings.to()); - char buffer[127]; + // char buffer[127]; String nodename = haspGetNodename(); String httpMessage((char *)0); httpMessage.reserve(1500); @@ -926,7 +924,7 @@ void httpHandleEspFirmware() if(!httpIsAuthenticated(F("/espfirmware"))) return; String nodename = haspGetNodename(); - char buffer[127]; + // char buffer[127]; String httpMessage((char *)0); httpMessage.reserve(1500); httpMessage += String(F("

")); @@ -949,7 +947,7 @@ void httpHandleResetConfig() bool resetConfirmed = webServer.arg(F("confirm")) == F("yes"); String nodename = haspGetNodename(); - char buffer[127]; + // char buffer[127]; String httpMessage((char *)0); httpMessage.reserve(1500); @@ -1066,11 +1064,12 @@ void httpReconnect() //////////////////////////////////////////////////////////////////////////////////////////////////// void httpLoop(bool wifiIsConnected) { - if(httpEnable) + if(httpEnable) { if(webServerStarted) webServer.handleClient(); else httpReconnect(); + } } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1081,7 +1080,7 @@ bool httpGetConfig(const JsonObject & settings) settings[FPSTR(F_CONFIG_USER)] = httpUser; settings[FPSTR(F_CONFIG_PASS)] = httpPassword; - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return true; @@ -1112,7 +1111,7 @@ bool httpSetConfig(const JsonObject & settings) httpPort = settings[FPSTR(F_CONFIG_PORT)].as(); } - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return changed; diff --git a/src/hasp_mdns.cpp b/src/hasp_mdns.cpp index c573c222..4cd6b113 100644 --- a/src/hasp_mdns.cpp +++ b/src/hasp_mdns.cpp @@ -48,7 +48,7 @@ bool mdnsGetConfig(const JsonObject & settings) settings[F_CONFIG_ENABLE] = mdnsEnabled; - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return true; diff --git a/src/hasp_spiffs.cpp b/src/hasp_spiffs.cpp index f91f438a..4019b040 100644 --- a/src/hasp_spiffs.cpp +++ b/src/hasp_spiffs.cpp @@ -47,7 +47,7 @@ void spiffsSetup() #else if(!SPIFFS.begin(true)) { #endif - sprintf(msg, PSTR("FILE: %sSPI flash init failed. Unable to mount FS.")); + sprintf(msg, PSTR("FILE: %%sSPI flash init failed. Unable to mount FS.")); errorPrintln(msg); } else { sprintf(msg, PSTR("FILE: [SUCCESS] SPI flash FS mounted")); diff --git a/src/hasp_tft.cpp b/src/hasp_tft.cpp index ecb32d05..fdbb7291 100644 --- a/src/hasp_tft.cpp +++ b/src/hasp_tft.cpp @@ -79,7 +79,7 @@ void tftShowConfig(TFT_eSPI & tft) sprintf_P(buffer, PSTR("TFT: TFT_eSPI ver = %s"), tftSetup.version.c_str()); debugPrintln(buffer); - sprintf_P(buffer, PSTR("TFT: Processor = ESP%i"), tftSetup.esp, HEX); + sprintf_P(buffer, PSTR("TFT: Processor = ESP%i"), tftSetup.esp); debugPrintln(buffer); sprintf_P(buffer, PSTR("TFT: Frequency = %i MHz"), ESP.getCpuFreqMHz()); debugPrintln(buffer); diff --git a/src/hasp_wifi.cpp b/src/hasp_wifi.cpp index cbd62ddb..33138023 100644 --- a/src/hasp_wifi.cpp +++ b/src/hasp_wifi.cpp @@ -211,7 +211,7 @@ bool wifiGetConfig(const JsonObject & settings) settings[FPSTR(F_CONFIG_SSID)] = String(wifiSsid.c_str()); settings[FPSTR(F_CONFIG_PASS)] = String(wifiPassword.c_str()); - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return true; @@ -241,7 +241,7 @@ bool wifiSetConfig(const JsonObject & settings) wifiPassword = settings[FPSTR(F_CONFIG_PASS)].as().c_str(); } - size_t size = serializeJson(settings, Serial); + serializeJson(settings, Serial); Serial.println(); return changed; diff --git a/src/lv_theme_hasp.c b/src/lv_theme_hasp.c index c62de9e0..b8ce886d 100644 --- a/src/lv_theme_hasp.c +++ b/src/lv_theme_hasp.c @@ -36,7 +36,7 @@ static lv_style_t label_prim; static lv_style_t label_sec; static lv_style_t label_hint; -static lv_style_t btn_rel, btn_pr, btn_trel, btn_tpr, btn_ina; +// static lv_style_t btn_rel, btn_pr, btn_trel, btn_tpr, btn_ina; /*Saved input parameters*/ static uint16_t _hue;