Skip to content

Commit 8755372

Browse files
authored
Lvgl9.2.2 (#211)
* Remove sw_rotate * Removed unused code * LVGL version to 9.2.2 * Enable all devices * Updated markdown * Test hardware rotation st7701 * Test use underlying driver for swap and mirror * Reenabled code * test * Use define for DISPLAY_SOFTWARE_ROTATION
1 parent 070458a commit 8755372

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/esp32_smartdisplay.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ void smartdisplay_init()
194194
// Setup TFT display
195195
display = lvgl_lcd_init();
196196

197+
#ifndef DISPLAY_SOFTWARE_ROTATION
198+
// Register callback for hardware rotation
199+
lv_display_add_event_cb(display, lvgl_display_resolution_changed_callback, LV_EVENT_RESOLUTION_CHANGED, NULL);
200+
#endif
201+
197202
// Clear screen
198203
lv_obj_clean(lv_scr_act());
199204
// Turn backlight on (50%)
@@ -210,3 +215,34 @@ void smartdisplay_init()
210215
lv_indev_enable(indev, true);
211216
#endif
212217
}
218+
219+
#ifndef DISPLAY_SOFTWARE_ROTATION
220+
// Called when driver resolution is updated (including rotation)
221+
// Top of the display is top left when connector is at the bottom
222+
// The rotation values are relative to how you would rotate the physical display in the clockwise direction.
223+
// So, LV_DISPLAY_ROTATION_90 means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate.
224+
void lvgl_display_resolution_changed_callback(lv_event_t *event)
225+
{
226+
const esp_lcd_panel_handle_t panel_handle = display->user_data;
227+
switch (display->rotation)
228+
{
229+
case LV_DISPLAY_ROTATION_0:
230+
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, DISPLAY_SWAP_XY));
231+
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y));
232+
break;
233+
case LV_DISPLAY_ROTATION_90:
234+
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !DISPLAY_SWAP_XY));
235+
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, DISPLAY_MIRROR_X, !DISPLAY_MIRROR_Y));
236+
break;
237+
case LV_DISPLAY_ROTATION_180:
238+
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, DISPLAY_SWAP_XY));
239+
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !DISPLAY_MIRROR_X, !DISPLAY_MIRROR_Y));
240+
break;
241+
case LV_DISPLAY_ROTATION_270:
242+
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !DISPLAY_SWAP_XY));
243+
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y));
244+
break;
245+
}
246+
}
247+
248+
#endif

0 commit comments

Comments
 (0)