Hi @amirgon,
Thank you so much.
amirgon:
Which version of LVGL are you using?
lvgl/lvgl_micropython ver1.14
lvgl 7.10.1
@amirgon:
del
is a reserved Python word.
It is replaced by _del
(or delete
on older versions).
Please try using task._del
I tried to use task._del() as well but it could not avoid the exception.
@embeddedt
The safe alternative is lv_obj_clean(lv_scr_act())
, which will remove all objects on the screen without deleting the screen itself.
I also tried to use " lv_obj_clean(lv_scr_act())
but it caused the same exception so I suppose that deleting animation task and objects such as task._del() are needed in advance.
In C language code, lv_task_del(task) works but in micropython code, task._del() seems not to work.
More details
I am evaluating to switch from an application to another application.
At first I wrote some applications using LVGL in C language.
- using a sample of lv_demo_widgets.c, I ran lv_demo_widgets().
- The demo showed widgets on a screen and all widgets work fine interacting user actions .
- I added a feature to switch to another application by pressing a key as follows.
- When the specific key is pressed, lv_obj_clean(lv_scr_act()) is called to clean all widgets on the screen before running another application.
- But it caused an exception with Segmentation fault in the animation task procedure.
- I supposed that the animation task related to the deleted widgets is still alive. it caused the error since it lost the widget. 7. Therefore, I called lv_task_del() to remove the active animation task before calling v_obj_clean(lv_scr_act()).
- It worked fine. The exception never occurred in the C language environment.
Next, I tried to implement the same process into the python environment.
- using a sample of lv_demo_widgets.py, import this module and run lv_demo_widgets().
- The demo showed widgets on a screen and all widgets work fine interacting user actions .
- When the specific key is pressed, it runs a method that calls task._del() before calling the lv_obj_clean(lv_scr_act()) before running another python script.
- But it caused an exception with Segmentation fault in the animation task procedure despite the calling task._del().
I suppose that animation objects such as a_arc, a_ga, a_lm are still alive and they link each widget arc, gauge and linearmeter that are removed. Then the exception occurs.
I should delete the animation objects before clear screen. How can I stop the animation objects and removed.
the place where an exception with Segmentation fault occurred
After calling lv_obj_clean(lv_scr_act()),
An exception has occurred at
2139 lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
2140 {
2141 LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
2142
2144 return obj->parent; ← here
2144 }
in at 477 line in lv_anim.c
438 static void anim_task(lv_task_t * param)
439 {
…
474 if(new_value != a->current) {
475 a->current = new_value;
476 /*Apply the calculated value*/
477 if(a->exec_cb) a->exec_cb(a->var, new_value); ← in this function