diff --git a/CHANGELOG.md b/CHANGELOG.md index c2c550b1b..cbcea213a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ All notable changes to this project will be documented in this file. - LVGL touch more responsive (#25172) - VEML7700 lux/white rounding, add new command (#25150) - WifiManager name the setup AP as it is turned on (#25169) +- Berry `lv.start()` raises an error instead of crashing when the display can't start ### Removed diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_lvgl.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_lvgl.ino index f0bfae73d..a57ea01fe 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_lvgl.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_lvgl.ino @@ -111,7 +111,7 @@ public: }; LVBE_globals lvbe; -extern void start_lvgl(const char * uconfig); +extern bool start_lvgl(const char * uconfig); extern void lv_ex_get_started_1(void); extern "C" { @@ -496,7 +496,10 @@ extern "C" { if (argc == 1) { uconfig = be_tostring(vm, 1); } - start_lvgl(uconfig); + if (!start_lvgl(uconfig)) { + // abort here, otherwise any following lv.* call crashes with LVGL not initialized + be_raise(vm, "internal_error", "LVGL could not start, check display configuration (display.ini, Option A3)"); + } // call lv.splash_remove() to kill any current splash screen if (be_getglobal(vm, "lv")) { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_54_lvgl.ino b/tasmota/tasmota_xdrv_driver/xdrv_54_lvgl.ino index e245c8afe..f9f1eeef6 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_54_lvgl.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_54_lvgl.ino @@ -467,18 +467,21 @@ void lvgl_touchscreen_read(lv_indev_t *indev_drv, lv_indev_data_t *data) { ************************************************************/ extern Renderer *Init_uDisplay(const char *desc); -void start_lvgl(const char * uconfig); -void start_lvgl(const char * uconfig) { +// Returns true if LVGL is running (already or newly started), false on failure +bool start_lvgl(const char * uconfig); +bool start_lvgl(const char * uconfig) { if (lvgl_glue != nullptr) { AddLog(LOG_LEVEL_DEBUG_MORE, D_LOG_LVGL "LVGL was already initialized"); - return; + return true; } if (!renderer || uconfig) { renderer = Init_uDisplay((char*)uconfig); - AddLog(LOG_LEVEL_ERROR, "LVG: Could not start Universal Display"); - if (!renderer) return; + if (!renderer) { + AddLog(LOG_LEVEL_ERROR, "LVG: Could not start Universal Display"); + return false; + } } renderer->DisplayOnff(true); @@ -539,7 +542,7 @@ void start_lvgl(const char * uconfig) { delete lvgl_glue; lvgl_glue = nullptr; AddLog(LOG_LEVEL_ERROR, "LVG: Could not allocate buffers"); - return; + return false; } // Initialize LvGL display driver @@ -610,6 +613,7 @@ void start_lvgl(const char * uconfig) { } AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_LVGL "LVGL initialized")); + return true; } /*********************************************************************************************\