Merge pull request #3 from tore-espressif/feature/color-inversion

Feature/color inversion
This commit is contained in:
Tomas Rezucha 2021-02-12 12:07:07 +01:00 committed by GitHub
commit b58a41ebc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 92 additions and 55 deletions

29
.editorconfig Normal file
View file

@ -0,0 +1,29 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{*.md,*.rst}]
trim_trailing_whitespace = false
[{Makefile,*.mk,*.bat}]
indent_style = tab
indent_size = 2
[{*.cmake,CMakeLists.txt}]
indent_style = space
indent_size = 4
max_line_length = 120
[{*.sh,*.yml}]
indent_style = space
indent_size = 2

View file

@ -579,16 +579,17 @@ menu "LVGL TFT Display controller"
default 2 default 2
config LV_INVERT_DISPLAY config LV_INVERT_DISPLAY
bool "IN DEPRECATION - Invert display." bool "IN DEPRECATION - Invert display." if LV_TFT_DISPLAY_CONTROLLER_RA8875
default y if LV_PREDEFINED_DISPLAY_M5STACK default n
help help
If text is backwards on your display, try enabling this. If text is backwards on your display, try enabling this.
config LV_INVERT_COLORS 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 || LV_TFT_DISPLAY_CONTROLLER_SSD1306 || LV_TFT_DISPLAY_CONTROLLER_SH1107 || LV_TFT_DISPLAY_CONTROLLER_HX8357
default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC
help help
If the colors look inverted on your display, try enabling this. 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 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 bool "Handle Backlight and TFT power for M5StickC using AXP192." if LV_PREDEFINED_DISPLAY_M5STICKC || LV_TFT_DISPLAY_CONTROLLER_ST7735S

View file

@ -200,8 +200,10 @@ void hx8357_init(void)
hx8357_set_rotation(1); hx8357_set_rotation(1);
#if HX8357_INVERT_DISPLAY #if HX8357_INVERT_COLORS
hx8357_send_cmd(HX8357_INVON);; hx8357_send_cmd(HX8357_INVON);
#else
hx8357_send_cmd(HX8357_INVOFF);
#endif #endif
hx8357_enable_backlight(true); hx8357_enable_backlight(true);

View file

@ -40,6 +40,7 @@ extern "C" {
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL #define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL
#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL #define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL #if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
#define HX8357_BCKL_ACTIVE_LVL 1 #define HX8357_BCKL_ACTIVE_LVL 1
@ -47,9 +48,6 @@ extern "C" {
#define HX8357_BCKL_ACTIVE_LVL 0 #define HX8357_BCKL_ACTIVE_LVL 0
#endif #endif
// if text/images are backwards, try setting this to 1
#define HX8357_INVERT_DISPLAY CONFIG_LV_INVERT_DISPLAY
/******************* /*******************
* HX8357B/D REGS * HX8357B/D REGS

View file

@ -82,7 +82,7 @@ void sh1107_init(void)
{0xDA, {0}, 0}, // Set com pins {0xDA, {0}, 0}, // Set com pins
{0x12, {0}, 0}, // ...value {0x12, {0}, 0}, // ...value
{0xA4, {0}, 0}, // output ram to display {0xA4, {0}, 0}, // output ram to display
#if defined CONFIG_LV_INVERT_DISPLAY #if defined CONFIG_LV_INVERT_COLORS
{0xA7, {0}, 0}, // inverted display {0xA7, {0}, 0}, // inverted display
#else #else
{0xA6, {0}, 0}, // Non-inverted display {0xA6, {0}, 0}, // Non-inverted display

View file

@ -113,7 +113,7 @@ void ssd1306_init(void)
uint8_t display_mode = 0; uint8_t display_mode = 0;
#if defined CONFIG_LV_INVERT_DISPLAY #if defined CONFIG_LV_INVERT_COLORS
display_mode = OLED_CMD_DISPLAY_INVERTED; display_mode = OLED_CMD_DISPLAY_INVERTED;
#else #else
display_mode = OLED_CMD_DISPLAY_NORMAL; display_mode = OLED_CMD_DISPLAY_NORMAL;

View file

@ -65,7 +65,13 @@ void st7789_init(void)
{ST7789_CABCCTRL, {0xBE}, 1}, {ST7789_CABCCTRL, {0xBE}, 1},
{ST7789_MADCTL, {0x00}, 1}, // Set to 0x28 if your display is flipped {ST7789_MADCTL, {0x00}, 1}, // Set to 0x28 if your display is flipped
{ST7789_COLMOD, {0x55}, 1}, {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}, {ST7789_RGBCTRL, {0x00, 0x1B}, 2},
{0xF2, {0x08}, 1}, {0xF2, {0x08}, 1},
{ST7789_GAMSET, {0x01}, 1}, {ST7789_GAMSET, {0x01}, 1},

View file

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