Description
Hi ,
I moved my code from esp-idf v4 to v5.4.1 and migrate lvgl v8 to v9.
My display is based on st7789.
My previous configuration worked perfectly, but i had to upgrade to esp-idf sdk v5 for bluetooth reason. After impossibility to have a working solution with lvgl v8, I decided to shift to v9. Almost all is fine now exept screen orientation.
What MCU/Processor/Board and compiler are you using?
ESP32S3 Custom board, gcc integrated in esp-idf install.
What LVGL version are you using?
V9.2.2
What do you want to achieve?
Turn to 270degres the screen to have landscape display format.
What have you tried so far?
I have used lv_display_set_rotation(display, LV_DISPLAY_ROTATION_270); in the init step of the code, resulting in wrong screen.
I also played all the possibility with esp_lcd_panel_swap_xy(panel_handle, false) and esp_lcd_panel_mirror(panel_handle, false, false) without finding the good combinaison.
I also consult the documentation before to post. But I wonder if I need to overload the flush_cb with computation and memory usage just for this.
In lvgl v8, it was only a setting in the driver init. I have the feeling that the esp_lcd layer bring more complexity than advantage for the moment. I hope i’m just missing something.
( Picture below)
Code to reproduce
With lvgl v8 and the use of
// disp_drv.sw_rotate = 1;
// disp_drv.rotated = 1;
It worked fine.
Here is the initialization procedure of the new code
ESP_LOGI(TAG_GUI, "Install panel IO");
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_io_spi_config_t io_config = {
.dc_gpio_num = EXAMPLE_PIN_NUM_LCD_DC,
.cs_gpio_num = EXAMPLE_PIN_NUM_CS,
.pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
.lcd_cmd_bits = EXAMPLE_LCD_CMD_BITS,
.lcd_param_bits = EXAMPLE_LCD_PARAM_BITS,
.spi_mode = 0,
.trans_queue_depth = 10,
};
// Attach the LCD to the SPI bus
ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_HOST, &io_config, &io_handle));
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = EXAMPLE_PIN_NUM_RST,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.bits_per_pixel = 16,
};
ESP_LOGI(TAG_GUI, "Install st7789 panel driver");
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, true));
// // the gap is LCD panel specific, even panels with the same driver IC, can have different gap value
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle,0, 0));
// user can flush pre-defined pattern to the screen before we turn on the screen or backlight
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
ESP_LOGI(TAG_GUI, "Turn on LCD backlight");
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
ESP_LOGI(TAG_GUI, "Initialize LVGL library");
lv_init();
ESP_LOGI(TAG_GUI, "Initialize LVGL library done");
// create a lvgl display
lv_display_t *display = lv_display_create(EXAMPLE_LCD_H_RES, EXAMPLE_LCD_V_RES);
// alloc draw buffers used by LVGL
// it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized
size_t draw_buffer_sz = EXAMPLE_LCD_H_RES * EXAMPLE_LVGL_DRAW_BUF_LINES * sizeof(lv_color16_t);
void *buf1 = spi_bus_dma_memory_alloc(LCD_HOST, draw_buffer_sz, 0);
assert(buf1);
void *buf2 = spi_bus_dma_memory_alloc(LCD_HOST, draw_buffer_sz, 0);
assert(buf2);
// initialize LVGL draw buffers
lv_display_set_buffers(display, buf1, buf2, draw_buffer_sz, LV_DISPLAY_RENDER_MODE_PARTIAL);
// associate the mipi panel handle to the display
lv_display_set_user_data(display, panel_handle);
// set color depth
lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565);
lv_display_set_rotation(display, LV_DISPLAY_ROTATION_270); //ORIENTATION HERE
// set the callback which can copy the rendered image to an area of the display
lv_display_set_flush_cb(display, example_lvgl_flush_cb);
Screenshot and/or video
With orientation function, I have an abnormal behavior:
Without orientation function, screen looks normal :
Square Line Studio 1.5.1 design:
Thanls a lot for your help, migration was a huge works, but i’m almost at the end.
I hope an easy solution can be found ( like it was with lvgl v8).