- board: ESP32-S3-WROOM-1
- ESP-IDF version: 5.3
- LVGL version: 9.1
- LCD Screen: ST7282 display controlled by RGB888
Test display of an image (in 3 copies) stored in the ESP32 flash (SPIFFS file system).
Here is the code for my 'Screen_Init' function to show you configurations:
- esp_err_t Screen_Init(void)
- {
- static lv_display_t *display = NULL;
- ESP_LOGI(TAG, "Install RGB LCD panel driver");
- esp_lcd_panel_handle_t panel_handle = NULL;
- esp_lcd_rgb_panel_config_t panel_config = {
- .data_width = 8, // RGB888 in parallel mode, thus 8bit in width
- .bits_per_pixel = 24,
- .psram_trans_align = 64,
- .num_fbs = 2,
- .clk_src = LCD_CLK_SRC_DEFAULT,
- .disp_gpio_num = LCD_PIN_NUM_DISP_EN,
- .pclk_gpio_num = LCD_PIN_NUM_PCLK,
- .vsync_gpio_num = LCD_PIN_NUM_VSYNC,
- .hsync_gpio_num = LCD_PIN_NUM_HSYNC,
- .de_gpio_num = LCD_PIN_NUM_DE,
- .data_gpio_nums = {
- LCD_PIN_NUM_DATA0,
- LCD_PIN_NUM_DATA1,
- LCD_PIN_NUM_DATA2,
- LCD_PIN_NUM_DATA3,
- LCD_PIN_NUM_DATA4,
- LCD_PIN_NUM_DATA5,
- LCD_PIN_NUM_DATA6,
- LCD_PIN_NUM_DATA7,
- },
- .timings = {
- .pclk_hz = 27000000,
- .h_res = 480,
- .v_res = 272,
- // The following parameters should refer to LCD spec
- .hsync_back_porch = 43,
- .hsync_front_porch = 8,
- .hsync_pulse_width = 4,
- .vsync_back_porch = 12,
- .vsync_front_porch = 8,
- .vsync_pulse_width = 4,
- .flags.pclk_active_neg = true,
- },
- .flags = {
- .fb_in_psram = true, // allocate frame buffer in PSRAM
- .disp_active_low = 0,
- }
- };
- ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
- ESP_LOGI(TAG, "Register event callbacks");
- esp_lcd_rgb_panel_event_callbacks_t cbs = {
- .on_vsync = on_vsync_event,
- };
- ESP_ERROR_CHECK(esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, display));
- ESP_LOGI(TAG, "Initialize RGB LCD panel");
- ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
- ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
- esp_lcd_panel_disp_on_off(panel_handle, true);
- ESP_LOGI(TAG, "Initialize LVGL library");
- lv_init();
- void *buf1 = NULL;
- void *buf2 = NULL;
- ESP_LOGI(TAG, "Use frame buffers as LVGL draw buffers");
- ESP_ERROR_CHECK(esp_lcd_rgb_panel_get_frame_buffer(panel_handle, 2, &buf1, &buf2));
- display = lv_display_create(480, 272);
- lv_display_set_flush_cb (display, lvgl_flush_cb);
- lv_display_set_user_data(display, panel_handle);
- // initialize LVGL draw buffers
- lv_display_set_buffers(display, buf1, buf1, 480* 272* sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_FULL);
- ESP_LOGI(TAG, "Install LVGL tick timer");
- // Tick interface for LVGL (using esp_timer to generate 2ms periodic event)
- const esp_timer_create_args_t lvgl_tick_timer_args = {
- .callback = &increase_lvgl_tick,
- .name = "lvgl_tick"
- };
- esp_timer_handle_t lvgl_tick_timer = NULL;
- ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer));
- ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, LCD_LVGL_TICK_PERIOD_MS * 1000));
- lv_obj_t *scr = lv_disp_get_scr_act(display);
- /// Set cyan background
- lv_obj_set_style_bg_color(scr, (lv_color_t){0x00, 0xBC, 0xD4}, LV_PART_MAIN);
- /// Display an image readed in flash
- screen_display_image();
- /// main task creation
- while (1) {
- // raise the task priority of LVGL and/or reduce the handler period can improve the performance
- vTaskDelay(pdMS_TO_TICKS(10));
- // The task running lv_timer_handler should have lower priority than that running `lv_tick_inc`
- lv_timer_handler();
- }
- return ESP_OK;
- }
When pressing the reset button on the ESP32-S3-WROOM-1 card, the screen display changes randomly (color of images and background varies and display shifts, see photo). The bug only occurs when an image is retrieved from the flash. No problem displaying any element of the LVGL lib (lines, shapes...).
Tests and debugs carried out:
- console display of the first 50 bytes of the displayed frame buffer: data corresponds to expectations, so we have the right data in the frame buffer.
- same image stored in an array rather than in flash: no more bugs
- lower PCLK speed (e.g. 20MHz instead of 27MHz): no bugs (see photo attached to visualize the expected result)
- if you retrieve the image in flash before configuring the panel handle and lvgl, configure them and then display the image: no bug
https://drive.google.com/file/d/1Nq2kTN ... drive_link
Thank you in advance for your help.
PS: Don't hesitate to ask me for more details, I wanted to keep things fairly condensed.