Skip to content

Commit 64e0e55

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 64e0e55

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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)