Skip to content

Commit 24fc870

Browse files
committed
(fix) lvgl deinit on soft-reset
Include `lv_conf.h` in `mpconfigboard.h` so lvgl deinit is called on soft-reset, so calling `lvgl.deinit()` is no longer necessary. This closes #343
1 parent 40eb341 commit 24fc870

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

.github/workflows/micropython_lvgl_ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ jobs:
8383
make -j $(nproc) -C ports/rp2 BOARD=RPI_PICO USER_C_MODULES=../../user_modules/lv_binding_micropython/micropython.cmake
8484
8585
# ESP32 port
86+
# USER_C_MODULES defined in mpconfigboard.cmake
8687
- name: Build esp32 port
8788
if: matrix.port == 'esp32'
8889
run: |
8990
source tools/ci.sh && ci_esp32_idf_setup
9091
source tools/ci.sh && ci_esp32_build_common
91-
make -C ports/esp32 BOARD=ESP32_GENERIC_S3 USER_C_MODULES=../../user_modules/lv_binding_micropython/micropython.cmake
92+
make -C ports/esp32 BOARD=ESP32_GENERIC_S3
93+
9294

9395
# Unix port
9496
- name: Build unix port

gen/gen_mpy.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,11 +1362,23 @@ def register_int_ptr_type(convertor, *types):
13621362
void mp_lv_deinit_gc()
13631363
{
13641364
1365-
// mp_printf(&mp_plat_print, "[ DEINIT GC ]");
1366-
mp_lv_roots = MP_STATE_VM(mp_lv_roots) = NULL;
1367-
mp_lv_user_data = MP_STATE_VM(mp_lv_user_data) = NULL;
1368-
mp_lv_roots_initialized = MP_STATE_VM(mp_lv_roots_initialized) = 0;
1369-
lvgl_mod_initialized = MP_STATE_VM(lvgl_mod_initialized) = 0;
1365+
1366+
if (MP_STATE_VM(lvgl_mod_initialized)) {
1367+
// mp_printf(&mp_plat_print, "[ DEINIT GC ]");
1368+
mp_lv_roots = MP_STATE_VM(mp_lv_roots) = NULL;
1369+
mp_lv_user_data = MP_STATE_VM(mp_lv_user_data) = NULL;
1370+
mp_lv_roots_initialized = MP_STATE_VM(mp_lv_roots_initialized) = 0;
1371+
lvgl_mod_initialized = MP_STATE_VM(lvgl_mod_initialized) = 0;
1372+
}
1373+
1374+
}
1375+
1376+
void mp_deinit_lvgl_mod()
1377+
{
1378+
1379+
if (MP_STATE_VM(lvgl_mod_initialized)) {
1380+
mp_lv_deinit_gc();
1381+
}
13701382
13711383
}
13721384

include/lv_mp_mem_custom_include.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
#include <py/misc.h>
66
#include <py/gc.h>
77

8+
extern void mp_deinit_lvgl_mod();
9+
#define MICROPY_PORT_DEINIT_FUNC mp_deinit_lvgl_mod()
10+
811
#endif //__LV_MP_MEM_CUSTOM_INCLUDE_H

0 commit comments

Comments
 (0)