Skip to content

Commit

Permalink
Lvgl9.2.2 (#211)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rzeldent authored Nov 1, 2024
1 parent 070458a commit 8755372
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/esp32_smartdisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ void smartdisplay_init()
// Setup TFT display
display = lvgl_lcd_init();

#ifndef DISPLAY_SOFTWARE_ROTATION
// Register callback for hardware rotation
lv_display_add_event_cb(display, lvgl_display_resolution_changed_callback, LV_EVENT_RESOLUTION_CHANGED, NULL);
#endif

// Clear screen
lv_obj_clean(lv_scr_act());
// Turn backlight on (50%)
Expand All @@ -210,3 +215,34 @@ void smartdisplay_init()
lv_indev_enable(indev, true);
#endif
}

#ifndef DISPLAY_SOFTWARE_ROTATION
// Called when driver resolution is updated (including rotation)
// Top of the display is top left when connector is at the bottom
// The rotation values are relative to how you would rotate the physical display in the clockwise direction.
// So, LV_DISPLAY_ROTATION_90 means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate.
void lvgl_display_resolution_changed_callback(lv_event_t *event)
{
const esp_lcd_panel_handle_t panel_handle = display->user_data;
switch (display->rotation)
{
case LV_DISPLAY_ROTATION_0:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, DISPLAY_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y));
break;
case LV_DISPLAY_ROTATION_90:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !DISPLAY_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, DISPLAY_MIRROR_X, !DISPLAY_MIRROR_Y));
break;
case LV_DISPLAY_ROTATION_180:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, DISPLAY_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !DISPLAY_MIRROR_X, !DISPLAY_MIRROR_Y));
break;
case LV_DISPLAY_ROTATION_270:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !DISPLAY_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y));
break;
}
}

#endif

0 comments on commit 8755372

Please sign in to comment.