Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TFT_eSPI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
TFT_eSPI
Commits
f96c4225
Commit
f96c4225
authored
Nov 02, 2020
by
Bodmer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for choosing colour order on ST7735
See #639
parent
c8c63172
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
80 additions
and
65 deletions
+80
-65
TFT_Drivers/ST7735_Defines.h
TFT_Drivers/ST7735_Defines.h
+14
-0
TFT_Drivers/ST7735_Init.h
TFT_Drivers/ST7735_Init.h
+7
-5
TFT_Drivers/ST7735_Rotation.h
TFT_Drivers/ST7735_Rotation.h
+32
-55
TFT_eSPI.h
TFT_eSPI.h
+1
-1
User_Setup.h
User_Setup.h
+1
-1
User_Setups/Setup2_ST7735.h
User_Setups/Setup2_ST7735.h
+5
-0
User_Setups/Setup43_ST7735.h
User_Setups/Setup43_ST7735.h
+6
-0
User_Setups/Setup7_ST7735_128x128.h
User_Setups/Setup7_ST7735_128x128.h
+5
-0
User_Setups/Setup9_ST7735_Overlap.h
User_Setups/Setup9_ST7735_Overlap.h
+6
-0
User_Setups/SetupX_Template.h
User_Setups/SetupX_Template.h
+1
-1
library.json
library.json
+1
-1
library.properties
library.properties
+1
-1
No files found.
TFT_Drivers/ST7735_Defines.h
View file @
f96c4225
...
...
@@ -106,6 +106,20 @@
#define TFT_MAD_MH 0x04
#define TFT_MAD_RGB 0x00
#ifndef TFT_RGB_ORDER
#if defined(INITR_BLACKTAB) || defined(INITR_GREENTAB2) || defined(INITB)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#else
#if (TFT_RGB_ORDER == 1)
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
#else
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
#endif
#endif
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
...
...
TFT_Drivers/ST7735_Init.h
View file @
f96c4225
...
...
@@ -24,7 +24,7 @@
0x03
,
// 3 lines back porch
10
,
// 10 ms delay
ST7735_MADCTL
,
1
,
// 5: Memory access ctrl (directions), 1 arg:
0x40
,
// Row addr/col addr, bottom to top refresh
0x40
|
TFT_MAD_COLOR_ORDER
,
// Row addr/col addr, bottom to top refresh
ST7735_DISSET5
,
2
,
// 6: Display settings #5, 2 args, no delay:
0x15
,
// 1 clk cycle nonoverlap, 2 cycle gate
// rise, 3 cycle osc equalize
...
...
@@ -101,7 +101,7 @@
0x0E
,
ST7735_INVOFF
,
0
,
// 13: Don't invert display, no args, no delay
ST7735_MADCTL
,
1
,
// 14: Memory access control (directions), 1 arg:
0xC
8
,
// row addr/col addr, bottom to top refresh
0xC
0
|
TFT_MAD_COLOR_ORDER
,
// row addr/col addr, bottom to top refresh
ST7735_COLMOD
,
1
,
// 15: set color mode, 1 arg, no delay:
0x05
},
// 16-bit color
...
...
@@ -146,7 +146,8 @@
}
else
{
commandList
(
Rcmd1
);
commandList
(
Rcmd1
);
if
(
tabcolor
==
INITR_GREENTAB
)
{
commandList
(
Rcmd2green
);
...
...
@@ -157,7 +158,7 @@
{
commandList
(
Rcmd2green
);
writecommand
(
ST7735_MADCTL
);
writedata
(
0xC0
);
writedata
(
0xC0
|
TFT_MAD_COLOR_ORDER
);
colstart
=
2
;
rowstart
=
1
;
}
...
...
@@ -193,8 +194,9 @@
else
if
(
tabcolor
==
INITR_BLACKTAB
)
{
writecommand
(
ST7735_MADCTL
);
writedata
(
0xC0
);
writedata
(
0xC0
|
TFT_MAD_COLOR_ORDER
);
}
commandList
(
Rcmd3
);
}
}
TFT_Drivers/ST7735_Rotation.h
View file @
f96c4225
...
...
@@ -7,149 +7,126 @@
switch
(
rotation
)
{
case
0
:
if
(
tabcolor
==
INITR_BLACKTAB
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDER
);
}
else
if
(
tabcolor
==
INITR_GREENTAB2
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDER
);
colstart
=
2
;
rowstart
=
1
;
}
else
if
(
tabcolor
==
INITR_GREENTAB3
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
2
;
rowstart
=
3
;
}
else
if
(
tabcolor
==
INITR_GREENTAB128
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_MH
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_MH
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
0
;
rowstart
=
32
;
}
else
if
(
tabcolor
==
INITR_GREENTAB160x80
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_MH
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_MH
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
26
;
rowstart
=
1
;
}
else
if
(
tabcolor
==
INITR_REDTAB160x80
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_MH
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_MH
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
24
;
rowstart
=
0
;
}
else
if
(
tabcolor
==
INITB
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_
COLOR_ORDER
);
}
else
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDE
R
);
}
_width
=
_init_width
;
_height
=
_init_height
;
break
;
case
1
:
if
(
tabcolor
==
INITR_BLACKTAB
)
{
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDER
);
}
else
if
(
tabcolor
==
INITR_GREENTAB2
)
{
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDER
);
colstart
=
1
;
rowstart
=
2
;
}
else
if
(
tabcolor
==
INITR_GREENTAB3
)
{
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
3
;
rowstart
=
2
;
}
else
if
(
tabcolor
==
INITR_GREENTAB128
)
{
writedata
(
TFT_MAD_MV
|
TFT_MAD_MY
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MV
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
32
;
rowstart
=
0
;
}
else
if
(
tabcolor
==
INITR_GREENTAB160x80
)
{
writedata
(
TFT_MAD_MV
|
TFT_MAD_MY
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MV
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
1
;
rowstart
=
26
;
}
else
if
(
tabcolor
==
INITR_REDTAB160x80
)
{
writedata
(
TFT_MAD_MV
|
TFT_MAD_MY
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MV
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
0
;
rowstart
=
24
;
}
else
if
(
tabcolor
==
INITB
)
{
writedata
(
TFT_MAD_MV
|
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MV
|
TFT_MAD_MX
|
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDER
);
}
else
{
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MY
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
}
_width
=
_init_height
;
_height
=
_init_width
;
break
;
case
2
:
if
(
tabcolor
==
INITR_BLACKTAB
)
{
writedata
(
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_
COLOR_ORDER
);
}
else
if
(
tabcolor
==
INITR_GREENTAB2
)
{
writedata
(
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_
COLOR_ORDER
);
colstart
=
2
;
rowstart
=
1
;
}
else
if
(
tabcolor
==
INITR_GREENTAB3
)
{
writedata
(
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
2
;
rowstart
=
1
;
}
else
if
(
tabcolor
==
INITR_GREENTAB128
)
{
writedata
(
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
0
;
rowstart
=
0
;
}
else
if
(
tabcolor
==
INITR_GREENTAB160x80
)
{
writedata
(
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
26
;
rowstart
=
1
;
}
else
if
(
tabcolor
==
INITR_REDTAB160x80
)
{
writedata
(
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
24
;
rowstart
=
0
;
}
else
if
(
tabcolor
==
INITB
)
{
writedata
(
TFT_MAD_MY
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MY
|
TFT_MAD_
COLOR_ORDER
);
}
else
{
writedata
(
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_
COLOR_ORDE
R
);
}
_width
=
_init_width
;
_height
=
_init_height
;
break
;
case
3
:
if
(
tabcolor
==
INITR_BLACKTAB
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDER
);
}
else
if
(
tabcolor
==
INITR_GREENTAB2
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDER
);
colstart
=
1
;
rowstart
=
2
;
}
else
if
(
tabcolor
==
INITR_GREENTAB3
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
1
;
rowstart
=
2
;
}
else
if
(
tabcolor
==
INITR_GREENTAB128
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
0
;
rowstart
=
0
;
}
else
if
(
tabcolor
==
INITR_GREENTAB160x80
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
1
;
rowstart
=
26
;
}
else
if
(
tabcolor
==
INITR_REDTAB160x80
)
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
colstart
=
0
;
rowstart
=
24
;
}
else
if
(
tabcolor
==
INITB
)
{
writedata
(
TFT_MAD_MV
|
TFT_MAD_
RGB
);
writedata
(
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDER
);
}
else
{
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
BG
R
);
writedata
(
TFT_MAD_MX
|
TFT_MAD_MV
|
TFT_MAD_
COLOR_ORDE
R
);
}
_width
=
_init_height
;
_height
=
_init_width
;
break
;
// These next rotations are for bottum up BMP drawing
/* case 4:
writedata(ST7735_TFT_MAD_MX | ST7735_TFT_MAD_MY | ST7735_TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 5:
writedata(ST7735_TFT_MAD_MV | ST7735_TFT_MAD_MX | ST7735_TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
case 6:
writedata(ST7735_TFT_MAD_BGR);
_width = _init_width;
_height = _init_height;
break;
case 7:
writedata(ST7735_TFT_MAD_MY | ST7735_TFT_MAD_MV | ST7735_TFT_MAD_BGR);
_width = _init_height;
_height = _init_width;
break;
*/
}
TFT_eSPI.h
View file @
f96c4225
...
...
@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_
#define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.3.
3
"
#define TFT_ESPI_VERSION "2.3.
4
"
// Bit level feature flags
// Bit 0 set: viewport capability
...
...
User_Setup.h
View file @
f96c4225
...
...
@@ -60,7 +60,7 @@
// #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 display only
// For ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// For ST77
35, ST77
89 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
...
...
User_Setups/Setup2_ST7735.h
View file @
f96c4225
...
...
@@ -9,6 +9,11 @@
#define ST7735_REDTAB
// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
#define TFT_CS PIN_D8 // Chip select control pin D8
...
...
User_Setups/Setup43_ST7735.h
View file @
f96c4225
...
...
@@ -11,6 +11,12 @@
#define ST7735_GREENTAB160x80
// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
#ifdef ESP32
#define TFT_MISO 19
#define TFT_MOSI 23
...
...
User_Setups/Setup7_ST7735_128x128.h
View file @
f96c4225
...
...
@@ -9,6 +9,11 @@
#define ST7735_GREENTAB128 // For 128 x 128 display
// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
#define TFT_CS PIN_D8 // Chip select control pin D8
...
...
User_Setups/Setup9_ST7735_Overlap.h
View file @
f96c4225
...
...
@@ -9,6 +9,12 @@
#define ST7735_REDTAB
// For ST7735, ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
// #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact
// but saves pins for other functions. It is best not to connect MISO as some displays
// do not tristate that line wjen chip select is high!
...
...
User_Setups/SetupX_Template.h
View file @
f96c4225
...
...
@@ -57,7 +57,7 @@
// #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 display only
// For ST7789 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// For ST77
35, ST77
89 and ILI9341 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display
// #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
...
...
library.json
View file @
f96c4225
{
"name"
:
"TFT_eSPI"
,
"version"
:
"2.3.
3
"
,
"version"
:
"2.3.
4
"
,
"keywords"
:
"Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140"
,
"description"
:
"A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32"
,
"repository"
:
...
...
library.properties
View file @
f96c4225
name
=
TFT_eSPI
version
=
2.3.
3
version
=
2.3.
4
author
=
Bodmer
maintainer
=
Bodmer
sentence
=
TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment