Skip to content

Commit b58a41e

Browse files
authoredFeb 12, 2021
Merge pull request #3 from tore-espressif/feature/color-inversion
Feature/color inversion
2 parents cbb08b2 + 9326e16 commit b58a41e

File tree

8 files changed

+92
-55
lines changed

8 files changed

+92
-55
lines changed
 

‎.editorconfig

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# http://editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
indent_style = space
9+
indent_size = 4
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
[{*.md,*.rst}]
16+
trim_trailing_whitespace = false
17+
18+
[{Makefile,*.mk,*.bat}]
19+
indent_style = tab
20+
indent_size = 2
21+
22+
[{*.cmake,CMakeLists.txt}]
23+
indent_style = space
24+
indent_size = 4
25+
max_line_length = 120
26+
27+
[{*.sh,*.yml}]
28+
indent_style = space
29+
indent_size = 2

‎lvgl_tft/Kconfig

+20-19
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ menu "LVGL TFT Display controller"
109109
bool
110110
help
111111
ST7789 display controller.
112-
112+
113113
config LV_TFT_DISPLAY_CONTROLLER_GC9A01
114114
bool
115115
help
@@ -211,14 +211,14 @@ menu "LVGL TFT Display controller"
211211

212212
config LV_TFT_DISPLAY_X_OFFSET
213213
depends on LV_TFT_DISPLAY_OFFSETS
214-
int
214+
int
215215
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
216216
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
217217
default 0
218218

219219
config LV_TFT_DISPLAY_Y_OFFSET
220220
depends on LV_TFT_DISPLAY_OFFSETS
221-
int
221+
int
222222
default 53 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_LANDSCAPE || LV_DISPLAY_ORIENTATION_LANDSCAPE_INVERTED)
223223
default 40 if LV_PREDEFINED_DISPLAY_TTGO && (LV_DISPLAY_ORIENTATION_PORTRAIT || LV_DISPLAY_ORIENTATION_PORTRAIT_INVERTED)
224224
default 0
@@ -284,7 +284,7 @@ menu "LVGL TFT Display controller"
284284
config LV_TFT_DISPLAY_USER_CONTROLLER_GC9A01
285285
bool "GC9A01"
286286
select LV_TFT_DISPLAY_CONTROLLER_GC9A01
287-
select LV_TFT_DISPLAY_PROTOCOL_SPI
287+
select LV_TFT_DISPLAY_PROTOCOL_SPI
288288
config LV_TFT_DISPLAY_USER_CONTROLLER_ST7735S
289289
bool "ST7735S"
290290
select LV_TFT_DISPLAY_CONTROLLER_ST7735S
@@ -441,7 +441,7 @@ menu "LVGL TFT Display controller"
441441
config LV_FT81X_CONFIG_EVE_SUNFLOWER
442442
bool "EVE_SUNFLOWER"
443443
config LV_FT81X_CONFIG_EVE_CONNECTEVE
444-
bool "EVE_CONNECTEVE"
444+
bool "EVE_CONNECTEVE"
445445
endchoice
446446

447447
choice
@@ -579,16 +579,17 @@ menu "LVGL TFT Display controller"
579579
default 2
580580

581581
config LV_INVERT_DISPLAY
582-
bool "IN DEPRECATION - Invert display."
583-
default y if LV_PREDEFINED_DISPLAY_M5STACK
582+
bool "IN DEPRECATION - Invert display." if LV_TFT_DISPLAY_CONTROLLER_RA8875
583+
default n
584584
help
585585
If text is backwards on your display, try enabling this.
586586

587587
config LV_INVERT_COLORS
588-
bool "Invert colors in display" if LV_TFT_DISPLAY_CONTROLLER_ILI9341 || LV_TFT_DISPLAY_CONTROLLER_ST7735S || LV_TFT_DISPLAY_CONTROLLER_ILI9481
588+
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
589589
default y if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICKC
590590
help
591591
If the colors look inverted on your display, try enabling this.
592+
If it didn't help try LVGL configuration -> Swap the 2 bytes of RGB565 color.
592593

593594
config LV_M5STICKC_HANDLE_AXP192
594595
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"
769770
depends on LV_DISPLAY_USE_SPI_MISO
770771
range 0 39 if IDF_TARGET_ESP32
771772
range 0 43 if IDF_TARGET_ESP32S2
772-
773+
773774
default 19 if LV_PREDEFINED_PINS_TKOALA
774775
default 0
775776

@@ -790,7 +791,7 @@ menu "LVGL TFT Display controller"
790791
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
791792
range -1 39 if IDF_TARGET_ESP32
792793
range -1 43 if IDF_TARGET_ESP32S2
793-
794+
794795
default 22 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
795796
default -1
796797
help
@@ -801,7 +802,7 @@ menu "LVGL TFT Display controller"
801802
depends on LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
802803
range -1 39 if IDF_TARGET_ESP32
803804
range -1 43 if IDF_TARGET_ESP32S2
804-
805+
805806
default 21 if LV_PREDEFINED_PINS_TKOALA && LV_TFT_DISPLAY_SPI_TRANS_MODE_QIO
806807
default -1
807808
help
@@ -811,7 +812,7 @@ menu "LVGL TFT Display controller"
811812
int "GPIO for CLK (SCK / Serial Clock)" if LV_TFT_DISPLAY_PROTOCOL_SPI
812813
range 0 39 if IDF_TARGET_ESP32
813814
range 0 43 if IDF_TARGET_ESP32S2
814-
815+
815816
default 18 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
816817
default 13 if LV_PREDEFINED_DISPLAY_M5STICKC
817818
default 18 if LV_PREDEFINED_DISPLAY_ATAG
@@ -838,7 +839,7 @@ menu "LVGL TFT Display controller"
838839
depends on LV_DISPLAY_USE_SPI_CS
839840
range 0 39 if IDF_TARGET_ESP32
840841
range 0 43 if IDF_TARGET_ESP32S2
841-
842+
842843
default 5 if LV_PREDEFINED_PINS_38V1
843844
default 14 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
844845
default 5 if LV_PREDEFINED_DISPLAY_M5STICKC
@@ -865,7 +866,7 @@ menu "LVGL TFT Display controller"
865866
int "GPIO for DC (Data / Command)" if LV_TFT_DISPLAY_PROTOCOL_SPI
866867
range 0 39 if IDF_TARGET_ESP32
867868
range 0 43 if IDF_TARGET_ESP32S2
868-
869+
869870
depends on LV_DISPLAY_USE_DC
870871
default 19 if LV_PREDEFINED_PINS_38V1
871872
default 17 if LV_PREDEFINED_PINS_38V4
@@ -887,7 +888,7 @@ menu "LVGL TFT Display controller"
887888
int "GPIO for Reset" if LV_TFT_DISPLAY_PROTOCOL_SPI
888889
range 0 39 if IDF_TARGET_ESP32
889890
range 0 43 if IDF_TARGET_ESP32S2
890-
891+
891892
default 18 if LV_PREDEFINED_PINS_38V1
892893
default 25 if LV_PREDEFINED_PINS_38V4
893894
default 33 if LV_PREDEFINED_DISPLAY_M5STACK || LV_PREDEFINED_DISPLAY_M5STICK
@@ -908,7 +909,7 @@ menu "LVGL TFT Display controller"
908909
int "GPIO for Busy" if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
909910
range 0 39 if IDF_TARGET_ESP32
910911
range 0 43 if IDF_TARGET_ESP32S2
911-
912+
912913
default 35 if LV_TFT_DISPLAY_CONTROLLER_IL3820 || LV_TFT_DISPLAY_CONTROLLER_JD79653A || LV_TFT_DISPLAY_CONTROLLER_UC8151D
913914
default 35
914915

@@ -946,7 +947,7 @@ menu "LVGL TFT Display controller"
946947
depends on LV_ENABLE_BACKLIGHT_CONTROL
947948
range 0 39 if IDF_TARGET_ESP32
948949
range 0 43 if IDF_TARGET_ESP32S2
949-
950+
950951
default 23 if LV_PREDEFINED_PINS_38V1
951952
default 26 if LV_PREDEFINED_PINS_38V4
952953
default 32 if LV_PREDEFINED_DISPLAY_M5STACK
@@ -966,7 +967,7 @@ menu "LVGL TFT Display controller"
966967
int "GPIO for I2C SDA" if LV_TFT_DISPLAY_PROTOCOL_I2C
967968
range 0 39 if IDF_TARGET_ESP32
968969
range 0 43 if IDF_TARGET_ESP32S2
969-
970+
970971
default 5 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
971972
default 5
972973

@@ -977,7 +978,7 @@ menu "LVGL TFT Display controller"
977978
int "GPIO for I2C SCL" if LV_TFT_DISPLAY_PROTOCOL_I2C
978979
range 0 39 if IDF_TARGET_ESP32
979980
range 0 43 if IDF_TARGET_ESP32S2
980-
981+
981982
default 4 if LV_PREDEFINED_DISPLAY_WEMOS_LOLIN
982983
default 4
983984

‎lvgl_tft/hx8357.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Adafruit 3.5" TFT 320x480 + Touchscreen Breakout
88
* http://www.adafruit.com/products/2050
99
*
10-
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
10+
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
1111
* https://www.adafruit.com/product/3651
1212
*
1313
*/
@@ -177,7 +177,7 @@ void hx8357_init(void)
177177
vTaskDelay(120 / portTICK_RATE_MS);
178178

179179
ESP_LOGI(TAG, "Initialization.");
180-
180+
181181
//Send all the commands
182182
const uint8_t *addr = (displayType == HX8357B) ? initb : initd;
183183
uint8_t cmd, x, numArgs;
@@ -199,9 +199,11 @@ void hx8357_init(void)
199199
}
200200

201201
hx8357_set_rotation(1);
202-
203-
#if HX8357_INVERT_DISPLAY
204-
hx8357_send_cmd(HX8357_INVON);;
202+
203+
#if HX8357_INVERT_COLORS
204+
hx8357_send_cmd(HX8357_INVON);
205+
#else
206+
hx8357_send_cmd(HX8357_INVOFF);
205207
#endif
206208

207209
hx8357_enable_backlight(true);
@@ -211,15 +213,15 @@ void hx8357_init(void)
211213
void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
212214
{
213215
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
214-
216+
215217
/* Column addresses */
216218
uint8_t xb[] = {
217219
(uint8_t) (area->x1 >> 8) & 0xFF,
218220
(uint8_t) (area->x1) & 0xFF,
219221
(uint8_t) (area->x2 >> 8) & 0xFF,
220222
(uint8_t) (area->x2) & 0xFF,
221223
};
222-
224+
223225
/* Page addresses */
224226
uint8_t yb[] = {
225227
(uint8_t) (area->y1 >> 8) & 0xFF,
@@ -261,7 +263,7 @@ void hx8357_enable_backlight(bool backlight)
261263
void hx8357_set_rotation(uint8_t r)
262264
{
263265
r = r & 3; // can't be higher than 3
264-
266+
265267
switch(r) {
266268
case 0:
267269
r = MADCTL_MX | MADCTL_MY | MADCTL_RGB;
@@ -276,7 +278,7 @@ void hx8357_set_rotation(uint8_t r)
276278
r = MADCTL_MX | MADCTL_MV | MADCTL_RGB;
277279
break;
278280
}
279-
281+
280282
hx8357_send_cmd(HX8357_MADCTL);
281283
hx8357_send_data(&r, 1);
282284
}

‎lvgl_tft/hx8357.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Adafruit 3.5" TFT 320x480 + Touchscreen Breakout
88
* http://www.adafruit.com/products/2050
99
*
10-
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
10+
* Adafruit TFT FeatherWing - 3.5" 480x320 Touchscreen for Feathers
1111
* https://www.adafruit.com/product/3651
1212
*
1313
*/
@@ -40,16 +40,14 @@ extern "C" {
4040
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL
4141

4242
#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
43+
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
4344

4445
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
4546
#define HX8357_BCKL_ACTIVE_LVL 1
4647
#else
4748
#define HX8357_BCKL_ACTIVE_LVL 0
4849
#endif
4950

50-
// if text/images are backwards, try setting this to 1
51-
#define HX8357_INVERT_DISPLAY CONFIG_LV_INVERT_DISPLAY
52-
5351

5452
/*******************
5553
* HX8357B/D REGS

‎lvgl_tft/sh1107.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ void sh1107_init(void)
6262
{0x81, {0}, 0}, // Set display contrast
6363
{0x2F, {0}, 0}, // ...value
6464
{0x20, {0}, 0}, // Set memory mode
65-
{0xA0, {0}, 0}, // Non-rotated display
66-
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
65+
{0xA0, {0}, 0}, // Non-rotated display
66+
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
6767
{0xC8, {0}, 0}, // flipped vertical
6868
#elif defined CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT
6969
{0xC7, {0}, 0}, // flipped vertical
@@ -82,11 +82,11 @@ void sh1107_init(void)
8282
{0xDA, {0}, 0}, // Set com pins
8383
{0x12, {0}, 0}, // ...value
8484
{0xA4, {0}, 0}, // output ram to display
85-
#if defined CONFIG_LV_INVERT_DISPLAY
85+
#if defined CONFIG_LV_INVERT_COLORS
8686
{0xA7, {0}, 0}, // inverted display
8787
#else
8888
{0xA6, {0}, 0}, // Non-inverted display
89-
#endif
89+
#endif
9090
{0xAF, {0}, 0}, // Turn display on
9191
{0, {0}, 0xff},
9292
};
@@ -116,14 +116,14 @@ void sh1107_init(void)
116116
}
117117

118118
void sh1107_set_px_cb(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
119-
lv_color_t color, lv_opa_t opa)
119+
lv_color_t color, lv_opa_t opa)
120120
{
121121
/* buf_w will be ignored, the configured CONFIG_LV_DISPLAY_HEIGHT and _WIDTH,
122-
and CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE and _PORTRAIT will be used. */
122+
and CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE and _PORTRAIT will be used. */
123123
uint16_t byte_index = 0;
124124
uint8_t bit_index = 0;
125125

126-
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
126+
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
127127
byte_index = y + (( x>>3 ) * LV_VER_RES_MAX);
128128
bit_index = x & 0x7;
129129
#elif defined CONFIG_LV_DISPLAY_ORIENTATION_PORTRAIT
@@ -146,10 +146,10 @@ void sh1107_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
146146
uint32_t size = 0;
147147
void *ptr;
148148

149-
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
149+
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
150150
row1 = area->x1>>3;
151151
row2 = area->x2>>3;
152-
#else
152+
#else
153153
row1 = area->y1>>3;
154154
row2 = area->y2>>3;
155155
#endif
@@ -158,9 +158,9 @@ void sh1107_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
158158
sh1107_send_cmd(0x00 | columnLow); // Set Lower Column Start Address for Page Addressing Mode
159159
sh1107_send_cmd(0xB0 | i); // Set Page Start Address for Page Addressing Mode
160160
size = area->y2 - area->y1 + 1;
161-
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
161+
#if defined CONFIG_LV_DISPLAY_ORIENTATION_LANDSCAPE
162162
ptr = color_map + i * LV_VER_RES_MAX;
163-
#else
163+
#else
164164
ptr = color_map + i * LV_HOR_RES_MAX;
165165
#endif
166166
if(i != row2){

0 commit comments

Comments
 (0)
Failed to load comments.