Skip to content

Commit

Permalink
invert st7789
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Dec 6, 2023
1 parent b4d2835 commit 2c79759
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 55 deletions.
72 changes: 36 additions & 36 deletions include/esp32_smartdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
#define ST7789_SPI_BUS_CONFIG {.mosi_io_num=13,.sclk_io_num=12,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define ST7789_IO_SPI_CONFIG {.cs_gpio_num=10,.dc_gpio_num=11,.spi_mode=SPI_MODE0,.pclk_hz=24000000,.trans_queue_depth=10,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define ST7789_PANEL_DEV_CONFIG {.reset_gpio_num=1,.color_space=ESP_LCD_COLOR_SPACE_RGB,.bits_per_pixel=16}
#define PANEL_ROT_NONE_SWAP_XY false
#define PANEL_ROT_NONE_MIRROR_X false
#define PANEL_ROT_NONE_MIRROR_Y false
#define PANEL_SWAP_XY false
#define PANEL_MIRROR_X false
#define PANEL_MIRROR_Y false
#ifdef ESP32_1732S019C
#define USES_GT911
#include "esp_lcd_touch_gt911.h"
#define GT911_I2C_HOST 0
#define GT911_I2C_CONFIG {.mode=I2C_MODE_MASTER,.sda_io_num=9,.scl_io_num=46,.sda_pullup_en=GPIO_PULLUP_ENABLE,.scl_pullup_en=GPIO_PULLUP_ENABLE,.master={.clk_speed=400000}}
#define GT911_IO_I2C_CONFIG {.dev_addr=ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS,.control_phase_bytes=1,.lcd_cmd_bits=16,.flags={.disable_control_phase=1}}
#define GT911_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_3,.int_gpio_num=GPIO_NUM_8}
#define TOUCH_ROT_NONE_SWAP_X false
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X false
#define TOUCH_ROT_SWAP_Y false
#endif
#endif

Expand All @@ -62,9 +62,9 @@
#define GC9A01_SPI_BUS_CONFIG {.mosi_io_num=7,.miso_io_num=-1,.sclk_io_num=6,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define GC9A01_IO_SPI_CONFIG {.cs_gpio_num=10,.dc_gpio_num=2,.spi_mode=SPI_MODE0,.pclk_hz=80000000,.trans_queue_depth=10,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define GC9A01_PANEL_DEV_CONFIG {.reset_gpio_num=-1,.color_space=ESP_LCD_COLOR_SPACE_BGR,.bits_per_pixel=16}
#define PANEL_ROT_NONE_SWAP_XY false
#define PANEL_ROT_NONE_MIRROR_X true
#define PANEL_ROT_NONE_MIRROR_Y false
#define PANEL_SWAP_XY false
#define PANEL_MIRROR_X true
#define PANEL_MIRROR_Y false
// Touch
#ifdef ESP32_2424S012C
#define USES_CST816S
Expand All @@ -73,8 +73,8 @@
#define CST816S_I2C_CONFIG {.mode=I2C_MODE_MASTER,.sda_io_num=4,.scl_io_num=5,.sda_pullup_en=GPIO_PULLUP_ENABLE,.scl_pullup_en=GPIO_PULLUP_ENABLE,.master={ .clk_speed=400000}}
#define CST816S_IO_I2C_CONFIG {.dev_addr=ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS,.control_phase_bytes=1,.lcd_cmd_bits=8,.flags={.disable_control_phase=1}}
#define CST816S_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_1,.int_gpio_num=GPIO_NUM_0}
#define TOUCH_ROT_NONE_SWAP_X false
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X false
#define TOUCH_ROT_SWAP_Y false
#endif
#endif

Expand All @@ -90,18 +90,18 @@
#define ILI9341_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define ILI9341_IO_SPI_CONFIG {.cs_gpio_num=15,.dc_gpio_num=2,.spi_mode=SPI_MODE0,.pclk_hz=24000000,.trans_queue_depth=10,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define ILI9341_PANEL_DEV_CONFIG {.reset_gpio_num=-1,.color_space=ESP_LCD_COLOR_SPACE_BGR,.bits_per_pixel=16}
#define PANEL_ROT_NONE_SWAP_XY false
#define PANEL_ROT_NONE_MIRROR_X true
#define PANEL_ROT_NONE_MIRROR_Y false
#define PANEL_SWAP_XY false
#define PANEL_MIRROR_X true
#define PANEL_MIRROR_Y false
// Touch
#ifdef ESP32_2432S024R
#define USES_XPT2046
#define XPT2046_SPI_HOST SPI2_HOST
#define XPT2046_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define XPT2046_IO_SPI_CONFIG {.cs_gpio_num=33,.dc_gpio_num=-1,.spi_mode=SPI_MODE0,.pclk_hz=2000000,.trans_queue_depth=3,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define XPT2046_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_NC,.int_gpio_num=GPIO_NUM_36}
#define TOUCH_ROT_NONE_SWAP_X true
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X true
#define TOUCH_ROT_SWAP_Y false
#else
#ifdef ESP32_2432S024C
#define USES_CST816S
Expand All @@ -110,8 +110,8 @@
#define CST816S_I2C_CONFIG {.mode=I2C_MODE_MASTER,.sda_io_num=33,.scl_io_num=32,.sda_pullup_en=GPIO_PULLUP_ENABLE,.scl_pullup_en=GPIO_PULLUP_ENABLE,.master={.clk_speed=400000}}
#define CST816S_IO_I2C_CONFIG {.dev_addr=ESP_LCD_TOUCH_IO_I2C_CST816S_ADDRESS,.control_phase_bytes=1,.lcd_cmd_bits=8,.flags={.disable_control_phase=1}}
#define CST816S_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_25,.int_gpio_num=GPIO_NUM_NC}
#define TOUCH_ROT_NONE_SWAP_X false
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X false
#define TOUCH_ROT_SWAP_Y false
#endif
#endif
// Build in RGB LED
Expand Down Expand Up @@ -139,17 +139,17 @@
#define ILI9341_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define ILI9341_IO_SPI_CONFIG {.cs_gpio_num=15,.dc_gpio_num=2,.spi_mode=SPI_MODE0,.pclk_hz=24000000,.trans_queue_depth=10,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define ILI9341_PANEL_DEV_CONFIG {.reset_gpio_num=-1,.color_space=ESP_LCD_COLOR_SPACE_BGR,.bits_per_pixel=16}
#define PANEL_ROT_NONE_SWAP_XY false
#define PANEL_ROT_NONE_MIRROR_X true
#define PANEL_ROT_NONE_MIRROR_Y false
#define PANEL_SWAP_XY false
#define PANEL_MIRROR_X true
#define PANEL_MIRROR_Y false
// Touch
#define USES_XPT2046
#define XPT2046_SPI_HOST SPI3_HOST
#define XPT2046_SPI_BUS_CONFIG {.mosi_io_num=32,.miso_io_num=39,.sclk_io_num=25,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define XPT2046_IO_SPI_CONFIG {.cs_gpio_num=33,.dc_gpio_num=-1,.spi_mode=SPI_MODE0,.pclk_hz=2000000,.trans_queue_depth=3,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define XPT2046_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_NC,.int_gpio_num=GPIO_NUM_36}
#define TOUCH_ROT_NONE_SWAP_X true
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X true
#define TOUCH_ROT_SWAP_Y false
// Build in RGB LED
#define HAS_RGB_LED
#define LED_PIN_R 4
Expand All @@ -175,9 +175,9 @@
#define ST7796_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define ST7796_IO_SPI_CONFIG {.cs_gpio_num=15,.dc_gpio_num=2,.spi_mode=SPI_MODE0,.pclk_hz=24000000,.trans_queue_depth=10,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define ST7796_PANEL_DEV_CONFIG {.reset_gpio_num=-1,.color_space=ESP_LCD_COLOR_SPACE_BGR,.bits_per_pixel=16}
#define PANEL_ROT_NONE_SWAP_XY false
#define PANEL_ROT_NONE_MIRROR_X true
#define PANEL_ROT_NONE_MIRROR_Y false
#define PANEL_SWAP_XY false
#define PANEL_MIRROR_X true
#define PANEL_MIRROR_Y false
// Touch
#ifdef ESP32_2432S032R
#define USES_XPT2046
Expand All @@ -186,8 +186,8 @@
#define XPT2046_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define XPT2046_IO_SPI_CONFIG {.cs_gpio_num=33,.dc_gpio_num=-1,.spi_mode=SPI_MODE0,.pclk_hz=2000000,.trans_queue_depth=3,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define XPT2046_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_NC,.int_gpio_num=GPIO_NUM_36}
#define TOUCH_ROT_NONE_SWAP_X true
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X true
#define TOUCH_ROT_SWAP_Y false
#else
#ifdef ESP32_2432S032C
#define USES_GT911
Expand All @@ -196,8 +196,8 @@
#define GT911_I2C_CONFIG {.mode=I2C_MODE_MASTER,.sda_io_num=33,.scl_io_num=32,.sda_pullup_en=GPIO_PULLUP_ENABLE,.scl_pullup_en=GPIO_PULLUP_ENABLE,.master={.clk_speed=400000}}
#define GT911_IO_I2C_CONFIG {.dev_addr=ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS,.control_phase_bytes=1,.lcd_cmd_bits=16,.flags={.disable_control_phase=1}}
#define GT911_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_25,.int_gpio_num=GPIO_NUM_NC}
#define TOUCH_ROT_NONE_SWAP_X false
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X false
#define TOUCH_ROT_SWAP_Y false
#endif
#endif
// Build in RGB LED
Expand Down Expand Up @@ -225,9 +225,9 @@
#define ST7796_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define ST7796_IO_SPI_CONFIG {.cs_gpio_num=15,.dc_gpio_num=2,.spi_mode=SPI_MODE0,.pclk_hz=24000000,.trans_queue_depth=10,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define ST7796_PANEL_DEV_CONFIG {.reset_gpio_num=-1,.color_space=ESP_LCD_COLOR_SPACE_BGR,.bits_per_pixel=16}
#define PANEL_ROT_NONE_SWAP_XY false
#define PANEL_ROT_NONE_MIRROR_X true
#define PANEL_ROT_NONE_MIRROR_Y false
#define PANEL_SWAP_XY false
#define PANEL_MIRROR_X true
#define PANEL_MIRROR_Y false
// Touch
#ifdef ESP32_3248S035R
#define USES_XPT2046
Expand All @@ -236,8 +236,8 @@
#define XPT2046_SPI_BUS_CONFIG {.mosi_io_num=13,.miso_io_num=12,.sclk_io_num=14,.quadwp_io_num=-1,.quadhd_io_num=-1}
#define XPT2046_IO_SPI_CONFIG {.cs_gpio_num=33,.dc_gpio_num=-1,.spi_mode=SPI_MODE0,.pclk_hz=2000000,.trans_queue_depth=3,.lcd_cmd_bits=8,.lcd_param_bits=8}
#define XPT2046_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_NC,.int_gpio_num=GPIO_NUM_36}
#define TOUCH_ROT_NONE_SWAP_X true
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X true
#define TOUCH_ROT_SWAP_Y false
#else
#ifdef ESP32_3248S035C
#define USES_GT911
Expand All @@ -246,8 +246,8 @@
#define GT911_I2C_CONFIG {.mode=I2C_MODE_MASTER,.sda_io_num=33,.scl_io_num=32,.sda_pullup_en=GPIO_PULLUP_ENABLE,.scl_pullup_en=GPIO_PULLUP_ENABLE,.master={.clk_speed=400000}}
#define GT911_IO_I2C_CONFIG {.dev_addr=ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS,.control_phase_bytes=1,.lcd_cmd_bits=16,.flags={.disable_control_phase=1}}
#define GT911_TOUCH_CONFIG {.x_max=TFT_WIDTH,.y_max=TFT_HEIGHT,.rst_gpio_num=GPIO_NUM_25,.int_gpio_num=GPIO_NUM_NC}
#define TOUCH_ROT_NONE_SWAP_X false
#define TOUCH_ROT_NONE_SWAP_Y false
#define TOUCH_ROT_SWAP_X false
#define TOUCH_ROT_SWAP_Y false
#endif
#endif
// Build in RGB LED
Expand Down
34 changes: 17 additions & 17 deletions src/esp32_smartdisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@ 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_ROT_NONE_SWAP_XY
#ifdef PANEL_SWAP_XY
switch (drv->rotated)
{
case LV_DISP_ROT_NONE:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, PANEL_ROT_NONE_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, PANEL_ROT_NONE_MIRROR_X, PANEL_ROT_NONE_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));
#ifdef USES_TOUCH
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_ROT_NONE_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_ROT_NONE_SWAP_Y));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_ROT_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_ROT_SWAP_Y));
#endif
break;
case LV_DISP_ROT_90:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !PANEL_ROT_NONE_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !PANEL_ROT_NONE_MIRROR_X, PANEL_ROT_NONE_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));
#ifdef USES_TOUCH
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_ROT_NONE_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_ROT_NONE_SWAP_Y));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_ROT_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_ROT_SWAP_Y));
#endif
break;
case LV_DISP_ROT_180:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, PANEL_ROT_NONE_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !PANEL_ROT_NONE_MIRROR_X, !PANEL_ROT_NONE_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));
#ifdef USES_TOUCH
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_ROT_NONE_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_ROT_NONE_SWAP_Y));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, TOUCH_ROT_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, TOUCH_ROT_SWAP_Y));
#endif
break;
case LV_DISP_ROT_270:
ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(panel_handle, !PANEL_ROT_NONE_SWAP_XY));
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, PANEL_ROT_NONE_MIRROR_X, !PANEL_ROT_NONE_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));
#ifdef USES_TOUCH
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_ROT_NONE_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_ROT_NONE_SWAP_Y));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_x(touch_handle, !TOUCH_ROT_SWAP_X));
ESP_ERROR_CHECK(esp_lcd_touch_set_mirror_y(touch_handle, !TOUCH_ROT_SWAP_Y));
#endif
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/smartdisplay_st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void lvgl_tft_init(lv_disp_drv_t *drv)
drv->user_data = panel_handle;
drv->flush_cb = st7789_lv_flush;

// Turn display on
//ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
// Invert color
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle, true));
}

#endif

0 comments on commit 2c79759

Please sign in to comment.