screen getting freezed after some time when i am using lvgl library with esp32

Description

What MCU/Processor/Board and compiler are you using?

I am using esp32UE

What do you want to achieve?

Solve the screen freeze issue.

What have you tried so far?

I tryed changing tasks as lv_task_t, esp_timer_handle_t and finally I am using freertos task

Code to reproduce

Add the relevant code snippets here.


#define lv_task_handler_time    5000
#define lv_tick_task_time       1000 
#define lv_task_create_time     1000

void task_update(lv_task_t task)
{
	// Updated valueswhich will be shown on the screen
}

static void lv_task_handler_task(void){
    while (1)
    {
        printf("esp_get_free_internal_heap_size() - %ld\n",esp_get_free_internal_heap_size());
        printf("esp_get_free_heap_size() - %ld\n",esp_get_free_heap_size());
        
        lv_task_handler();
        vTaskDelay(pdMS_TO_TICKS(lv_task_handler_time));
    }
}

static void init_disp(void){
    tft_interface_displaySetup();
    tft_interface_displayBackgroundColor(LV_COLOR_BLACK);
    aqi_display_aqi_tftApplication();
    vTaskDelay(pdMS_TO_TICKS(100));
    /* Create and start a periodic timer interrupt to call lv_tick_inc */
    const esp_timer_create_args_t periodic_timer_args = {
        .callback = &lv_tick_task,
        .name = "periodic_gui"};
    esp_timer_handle_t periodic_timer;
    ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
    ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * lv_tick_task_time));

    lv_task_t *task = lv_task_create(task_update, lv_task_create_time, LV_TASK_PRIO_MID, NULL);
    aqi_display_tft_interface_displayturnON(true);

    xTaskCreate(&lv_task_handler_task, "lv_task_handler_task", 2048, NULL, tskIDLE_PRIORITY, NULL);     
}

Screenshot and/or video

image

LVGL and Threads

LVGL is not thread-safe.

That means it is the programmer’s responsibility to see that no LVGL function is called while another LVGL call is in progress in another thread. This includes calls to lv_timer_handler().