Add 7789 color invert option

This commit is contained in:
Tomas Rezucha 2021-02-12 10:18:01 +01:00
parent cbb08b2c3d
commit c90f6a4831
3 changed files with 29 additions and 21 deletions

View file

@ -109,7 +109,7 @@ menu "LVGL TFT Display controller"
bool
help
ST7789 display controller.
config LV_TFT_DISPLAY_CONTROLLER_GC9A01
bool
help
@ -211,14 +211,14 @@ menu "LVGL TFT Display controller"
config LV_TFT_DISPLAY_X_OFFSET
depends on LV_TFT_DISPLAY_OFFSETS
int
int
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
default 0
config LV_TFT_DISPLAY_Y_OFFSET
depends on LV_TFT_DISPLAY_OFFSETS
int
int
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
default 0
@ -284,7 +284,7 @@ menu "LVGL TFT Display controller"
config LV_TFT_DISPLAY_USER_CONTROLLER_GC9A01
bool "GC9A01"
select LV_TFT_DISPLAY_CONTROLLER_GC9A01
select LV_TFT_DISPLAY_PROTOCOL_SPI
select LV_TFT_DISPLAY_PROTOCOL_SPI
config LV_TFT_DISPLAY_USER_CONTROLLER_ST7735S
bool "ST7735S"
select LV_TFT_DISPLAY_CONTROLLER_ST7735S
@ -441,7 +441,7 @@ menu "LVGL TFT Display controller"
config LV_FT81X_CONFIG_EVE_SUNFLOWER
bool "EVE_SUNFLOWER"
config LV_FT81X_CONFIG_EVE_CONNECTEVE
bool "EVE_CONNECTEVE"
bool "EVE_CONNECTEVE"
endchoice
choice
@ -585,10 +585,11 @@ menu "LVGL TFT Display controller"
If text is backwards on your display, try enabling this.
config LV_INVERT_COLORS
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481 || LV_TFT_DISPLAY_CONTROLLER_ST7789
default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC
help
If the colors look inverted on your display, try enabling this.
If it didn't help try LVGL configuration -> Swap the 2 bytes of RGB565 color.
config LV_M5STICKC_HANDLE_AXP192
bool "Handle Backlight and TFT power for M5StickC using AXP192." if LV_PREDEFINED_DISPLAY_M5STICKC || LV_TFT_DISPLAY_CONTROLLER_ST7735S
@ -769,7 +770,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISPLAY_USE_SPI_MISO
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 19 if LV_PREDEFINED_PINS_TKOALA
default 0
@ -790,7 +791,7 @@ menu "LVGL TFT Display controller"
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
range -1 39 if IDF_TARGET_ESP32
range -1 43 if IDF_TARGET_ESP32S2
default 22 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
default -1
help
@ -801,7 +802,7 @@ menu "LVGL TFT Display controller"
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
range -1 39 if IDF_TARGET_ESP32
range -1 43 if IDF_TARGET_ESP32S2
default 21 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
default -1
help
@ -811,7 +812,7 @@ menu "LVGL TFT Display controller"
int "GPIO for CLK (SCK / Serial Clock)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
default 13 if LV_PREDEFINED_DISPLAY_M5STICKC
default 18 if LV_PREDEFINED_DISPLAY_ATAG
@ -838,7 +839,7 @@ menu "LVGL TFT Display controller"
depends on LV_DISPLAY_USE_SPI_CS
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 5 if LV_PREDEFINED_PINS_38V1
default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
default 5 if LV_PREDEFINED_DISPLAY_M5STICKC
@ -865,7 +866,7 @@ menu "LVGL TFT Display controller"
int "GPIO for DC (Data / Command)" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
depends on LV_DISPLAY_USE_DC
default 19 if LV_PREDEFINED_PINS_38V1
default 17 if LV_PREDEFINED_PINS_38V4
@ -887,7 +888,7 @@ menu "LVGL TFT Display controller"
int "GPIO for Reset" if LV_TFT_DISPLAY_PROTOCOL_SPI
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 18 if LV_PREDEFINED_PINS_38V1
default 25 if LV_PREDEFINED_PINS_38V4
default 33 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
@ -908,7 +909,7 @@ menu "LVGL TFT Display controller"
int "GPIO for Busy" if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 35 if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
default 35
@ -946,7 +947,7 @@ menu "LVGL TFT Display controller"
depends on LV_ENABLE_BACKLIGHT_CONTROL
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 23 if LV_PREDEFINED_PINS_38V1
default 26 if LV_PREDEFINED_PINS_38V4
default 32 if LV_PREDEFINED_DISPLAY_M5STACK
@ -966,7 +967,7 @@ menu "LVGL TFT Display controller"
int "GPIO for I2C SDA" if LV_TFT_DISPLAY_PROTOCOL_I2C
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 5 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
default 5
@ -977,7 +978,7 @@ menu "LVGL TFT Display controller"
int "GPIO for I2C SCL" if LV_TFT_DISPLAY_PROTOCOL_I2C
range 0 39 if IDF_TARGET_ESP32
range 0 43 if IDF_TARGET_ESP32S2
default 4 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
default 4

View file

@ -65,7 +65,13 @@ void st7789_init(void)
{ST7789_CABCCTRL, {0xBE}, 1},
{ST7789_MADCTL, {0x00}, 1}, // Set to 0x28 if your display is flipped
{ST7789_COLMOD, {0x55}, 1},
{ST7789_INVON, {0}, 0},
#if ST7789_INVERT_COLORS == 1
{ST7789_INVON, {0}, 0}, // set inverted mode
#else
{ST7789_INVOFF, {0}, 0}, // set non-inverted mode
#endif
{ST7789_RGBCTRL, {0x00, 0x1B}, 2},
{0xF2, {0x08}, 1},
{ST7789_GAMSET, {0x01}, 1},
@ -86,7 +92,7 @@ void st7789_init(void)
gpio_set_direction(ST7789_DC, GPIO_MODE_OUTPUT);
gpio_pad_select_gpio(ST7789_RST);
gpio_set_direction(ST7789_RST, GPIO_MODE_OUTPUT);
#if ST7789_ENABLE_BACKLIGHT_CONTROL
gpio_pad_select_gpio(ST7789_BCKL);
gpio_set_direction(ST7789_BCKL, GPIO_MODE_OUTPUT);
@ -219,7 +225,7 @@ static void st7789_set_orientation(uint8_t orientation)
ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
uint8_t data[] =
uint8_t data[] =
{
#if CONFIG_LV_PREDEFINED_DISPLAY_TTGO
0x60, 0xA0, 0x00, 0xC0
@ -227,7 +233,7 @@ static void st7789_set_orientation(uint8_t orientation)
0xC0, 0x00, 0x60, 0xA0
#endif
};
ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
st7789_send_cmd(ST7789_MADCTL);

View file

@ -26,6 +26,7 @@ extern "C"
#define ST7789_BCKL CONFIG_LV_DISP_PIN_BCKL
#define ST7789_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define ST7789_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define ST7789_BCKL_ACTIVE_LVL 1