I am using LVGL 9 on an ESP32 board. Freertos(in arduino version).
In the main loop I initialize LVGL and drivers, in it I call lv_timer_handler, in it (as far as I understand), the handlers of pressing buttons are called. I hang on one of the handlers lv_screen_load_anim to switch between screens at the press of a button. So far everything is going well.
Now I want to show the WIFI icon on the screen. To do this, I create a new thread based on the wifi_test function, in which I call WiFi.status() in a loop and if it returns me false, I do something like lv_obj_set_style_text_color(objects.wifi_icon, lv_color_hex(ERROR_COLOR)); and if true - then lv_color_hex(OK_COLOR).
This still works relatively stable.
But now I press the button that switches screens, and with a fairly high probability wifi_test will hang on lv_obj_set_style_text_color. Apparently this is due to a collision with lv_screen_load_anim.
What should I do if I want to control graphics from another track? I tried using a mutex, wrapping every graphics call in my code in it, but that didn’t succeed.