Skip to content

Commit

Permalink
Add orientation choice menu for M5Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
C47D committed Mar 26, 2020
1 parent e00b3d0 commit 900c1d1
Show file tree
Hide file tree
Showing 5 changed files with 605 additions and 622 deletions.
24 changes: 21 additions & 3 deletions components/lvgl_esp32_drivers/lvgl_tft/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ menu "LittlevGL (LVGL) TFT Display controller"
config LVGL_PREDEFINED_DISPLAY_WROVER4
bool "ESP-Wrover-KIT v4.1"
config LVGL_PREDEFINED_DISPLAY_M5STACK
select LVGL_DISPLAY_ORIENTATION_LANDSCAPE
bool "M5Stack"
config LVGL_PREDEFINED_DISPLAY_ERTFT0356
bool "ER-TFT035-6"
Expand Down Expand Up @@ -80,16 +81,33 @@ menu "LittlevGL (LVGL) TFT Display controller"
config LVGL_TFT_DISPLAY_SPI_VSPI
bool "VSPI"
endchoice

choice
prompt "Display orientation"
default LVGL_DISPLAY_ORIENTATION_PORTRAIT
help
Display orientation.

config LVGL_DISPLAY_ORIENTATION_PORTRAIT
bool "Portrait"
config LVGL_DISPLAY_ORIENTATION_LANDSCAPE
bool "Landscape"
endchoice

config LVGL_DISPLAY_WIDTH
int "TFT display width in pixels." if LVGL_PREDEFINED_DISPLAY_NONE
default 240 if LVGL_PREDEFINED_DISPLAY_M5STACK
default 480 if LVGL_PREDEFINED_DISPLAY_ERTFT0356 || LVGL_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 240 if LVGL_PREDEFINED_DISPLAY_M5STACK && LVGL_DISPLAY_ORIENTATION_PORTRAIT
default 320 if LVGL_PREDEFINED_DISPLAY_M5STACK && LVGL_DISPLAY_ORIENTATION_LANDSCAPE
default 480 if LVGL_PREDEFINED_DISPLAY_ERTFT0356
default 480 if LVGL_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 320

config LVGL_DISPLAY_HEIGHT
int "TFT display height in pixels." if LVGL_PREDEFINED_DISPLAY_NONE
default 320 if LVGL_PREDEFINED_DISPLAY_M5STACK || LVGL_PREDEFINED_DISPLAY_ERTFT0356 || LVGL_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 320 if LVGL_PREDEFINED_DISPLAY_M5STACK && LVGL_DISPLAY_ORIENTATION_PORTRAIT
default 240 if LVGL_PREDEFINED_DISPLAY_M5STACK && LVGL_DISPLAY_ORIENTATION_LANDSCAPE
default 320 if LVGL_PREDEFINED_DISPLAY_ERTFT0356
default 320 if LVGL_PREDEFINED_DISPLAY_ADA_FEATHERWING
default 240

config LVGL_INVERT_DISPLAY
Expand Down
3 changes: 3 additions & 0 deletions components/lvgl_esp32_drivers/lvgl_tft/disp_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ extern "C" {
#define TFT_CONTROLLER_ST7789 2
#define TFT_CONTROLLER_HX8357 3

#define TFT_ORIENTATION_PORTRAIT 0
#define TFT_ORIENTATION_LANDSCAPE 1

/**********************
* TYPEDEFS
**********************/
Expand Down
9 changes: 7 additions & 2 deletions components/lvgl_esp32_drivers/lvgl_tft/ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,18 @@ void ili9341_init(void)

ili9341_enable_backlight(true);

#if ILI9341_INVERT_DISPLAY
#if (ILI9341_DISPLAY_ORIENTATION == TFT_ORIENTATION_LANDSCAPE)
uint8_t data[] = {0x08};
#elif (ILI9341_DISPLAY_ORIENTATION == TFT_ORIENTATION_PORTRAIT)
uint8_t data[] = {0x68};
#else
#pragma message "Choose an display orientation"
#endif

// this same command also sets rotation (portrait/landscape) and inverts colors.
// https://gist.github.com/motters/38a26a66020f674b6389063932048e4c#file-ili9844_defines-h-L24
ili9341_send_cmd(0x36);
ili9341_send_data(&data, 1);
#endif
}


Expand Down
7 changes: 7 additions & 0 deletions components/lvgl_esp32_drivers/lvgl_tft/ili9341.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ extern "C" {
#define ILI9341_BCKL_ACTIVE_LVL 0
#endif

#if (CONFIG_LVGL_DISPLAY_ORIENTATION_PORTRAIT)
#define ILI9341_DISPLAY_ORIENTATION TFT_ORIENTATION_PORTRAIT
#elif (CONFIG_LVGL_DISPLAY_ORIENTATION_LANDSCAPE)
#define ILI9341_DISPLAY_ORIENTATION TFT_ORIENTATION_LANDSCAPE
#endif


// if text/images are backwards, try setting this to 1
#define ILI9341_INVERT_DISPLAY CONFIG_LVGL_INVERT_DISPLAY

Expand Down

0 comments on commit 900c1d1

Please sign in to comment.