esp-bsp icon indicating copy to clipboard operation
esp-bsp copied to clipboard

esp_lvgl_port: apply rotation from display configuration (BSP-443)

Open cybekRT opened this issue 1 year ago • 2 comments

Initial rotation set in lvgl_port_display_cfg_t was not applied properly after display initialization. This commit adds call to update callback that sets the swap and mirror properties on panel.

Sample code that shows the behavior:

esp_lcd_panel_handle_t lcdPanelHandle;
ESP_ERROR_CHECK(esp_lcd_new_panel_gc9a01(lcdPanelIOHandle, &lcdPanelConfig, &lcdPanelHandle));

ESP_ERROR_CHECK(esp_lcd_panel_reset(lcdPanelHandle));
ESP_ERROR_CHECK(esp_lcd_panel_init(lcdPanelHandle));
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(lcdPanelHandle, 1));

const lvgl_port_display_cfg_t displayCfg = {
		.io_handle = lcdPanelIOHandle,
		.panel_handle = lcdPanelHandle,
		.buffer_size = 240 * 240,
		.double_buffer = 0,
		.hres = 240,
		.vres = 240,
		.monochrome = 0,
		.rotation = {
			.mirror_x = 0,
			.mirror_y = 1,
			.swap_xy = 0,
		},
		.flags.buff_dma = 0,
		.flags.buff_spiram = 0,
};
display = lvgl_port_add_disp(&displayCfg);

lv_obj_t* root = lv_disp_get_scr_act(display);
lv_obj_t* lHello = lv_label_create(root);
lv_label_set_text(lHello, "Hello world~!");
lv_obj_align(lHello, LV_ALIGN_CENTER, 0, 0);

After this, the rotation parameters are ignored and requires manual update of lvgl driver to reapply them. This PR makes the rotation being applied just after initialization, as expected. Tested on: https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-1.28

cybekRT avatar Jan 16 '24 00:01 cybekRT

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 16 '24 00:01 CLAassistant

@cybekRT Thank you for this PR. I was added your changes to update LVGL port PR here: https://github.com/espressif/esp-bsp/pull/320

espzav avatar Apr 11 '24 06:04 espzav