Skip to content

Commit

Permalink
Software Rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Dec 10, 2023
1 parent 9a7ec27 commit 45c0432
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/esp32_smartdisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ static void lvgl_update_callback(lv_disp_drv_t *drv)
{
esp_lcd_panel_handle_t panel_handle = disp_drv.user_data;
esp_lcd_touch_handle_t touch_handle = indev_drv.user_data;
#ifdef PANEL_SWAP_XY
switch (drv->rotated)
{
case LV_DISP_ROT_NONE:
#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y)
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, PANEL_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, PANEL_MIRROR_X, PANEL_MIRROR_Y));
#endif
#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y)
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_X, PANEL_GAP_Y));
#endif
Expand All @@ -39,8 +40,10 @@ static void lvgl_update_callback(lv_disp_drv_t *drv)
#endif
break;
case LV_DISP_ROT_90:
#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y)
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !PANEL_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !PANEL_MIRROR_X, PANEL_MIRROR_Y));
#endif
#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y)
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_Y, PANEL_GAP_X));
#endif
Expand All @@ -50,8 +53,10 @@ static void lvgl_update_callback(lv_disp_drv_t *drv)
#endif
break;
case LV_DISP_ROT_180:
#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y)
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, PANEL_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !PANEL_MIRROR_X, !PANEL_MIRROR_Y));
#endif
#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y)
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_X, PANEL_GAP_Y));
#endif
Expand All @@ -61,8 +66,10 @@ static void lvgl_update_callback(lv_disp_drv_t *drv)
#endif
break;
case LV_DISP_ROT_270:
#if defined(PANEL_SWAP_XY) && defined(PANEL_MIRROR_X) && defined(PANEL_MIRROR_Y)
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !PANEL_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, PANEL_MIRROR_X, !PANEL_MIRROR_Y));
#endif
#if defined(PANEL_GAP_X) || defined(PANEL_GAP_Y)
ESP_ERROR_CHECK(esp_lcd_panel_set_gap(panel_handle, PANEL_GAP_Y, PANEL_GAP_X));
#endif
Expand All @@ -72,7 +79,6 @@ static void lvgl_update_callback(lv_disp_drv_t *drv)
#endif
break;
}
#endif
}

void smartdisplay_init()
Expand Down
4 changes: 4 additions & 0 deletions src/smartdisplay_gc9a01.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ void gc9a01_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color16_t *co

void lvgl_tft_init(lv_disp_drv_t *drv)
{
// Hardware rotation is supported
drv->sw_rotate = 0;
drv->rotated = LV_DISP_ROT_NONE;

// Create SPI bus
const spi_bus_config_t spi_bus_config = GC9A01_SPI_BUS_CONFIG;
ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(GC9A01_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO));
Expand Down
4 changes: 4 additions & 0 deletions src/smartdisplay_ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ static void ili9341_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color

void lvgl_tft_init(lv_disp_drv_t *drv)
{
// Hardware rotation is supported
drv->sw_rotate = 0;
drv->rotated = LV_DISP_ROT_NONE;

// Create SPI bus
const spi_bus_config_t spi_bus_config = ILI9341_SPI_BUS_CONFIG;
ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ILI9341_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO));
Expand Down
4 changes: 4 additions & 0 deletions src/smartdisplay_rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ static void direct_io_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_col

void lvgl_tft_init(lv_disp_drv_t *drv)
{
// Hardware rotation is NOT supported
drv->sw_rotate = 1;
drv->rotated = LV_DISP_ROT_NONE;

// Create direct_io panel handle
esp_lcd_rgb_panel_config_t tft_panel_config = RBG_PANEL_CONFIG;
tft_panel_config.on_frame_trans_done = direct_io_frame_trans_done;
Expand Down
4 changes: 4 additions & 0 deletions src/smartdisplay_st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ static void st7789_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color1

void lvgl_tft_init(lv_disp_drv_t *drv)
{
// Hardware rotation is supported
drv->sw_rotate = 0;
drv->rotated = LV_DISP_ROT_NONE;

// Create SPI bus
const spi_bus_config_t spi_bus_config = ST7789_SPI_BUS_CONFIG;
ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ST7789_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO));
Expand Down
4 changes: 4 additions & 0 deletions src/smartdisplay_st7796.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ static void st7796_lv_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color1

void lvgl_tft_init(lv_disp_drv_t *drv)
{
// Hardware rotation is supported
drv->sw_rotate = 0;
drv->rotated = LV_DISP_ROT_NONE;

// Create SPI bus
const spi_bus_config_t spi_bus_config = ST7796_SPI_BUS_CONFIG;
ESP_ERROR_CHECK_WITHOUT_ABORT(spi_bus_initialize(ST7796_SPI_HOST, &spi_bus_config, SPI_DMA_CH_AUTO));
Expand Down

0 comments on commit 45c0432

Please sign in to comment.