mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2024-09-21 02:17:13 +00:00
Update HX8357D driver to support RGB and BGR displays
In setup add the following lines: // If green and blue swapped on display then change the RGB colour order // Only uncomment ONE of the following options #define TFT_RGB_ORDER TFT_RGB // Red-Green-Blue //#define TFT_RGB_ORDER TFT_BGR // Blue-Green-RED
This commit is contained in:
parent
39b0d6ab9a
commit
31b2de56c1
@ -39,6 +39,16 @@
|
||||
#define TFT_MAD_SS 0x02
|
||||
#define TFT_MAD_GS 0x01
|
||||
|
||||
#ifdef TFT_RGB_ORDER
|
||||
#if (TFT_RGB_ORDER == 1)
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
|
||||
#else
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
|
||||
#endif
|
||||
#else
|
||||
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
|
||||
#endif
|
||||
|
||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||
|
||||
|
||||
|
@ -97,7 +97,7 @@
|
||||
writedata(0x55); // 16 bit
|
||||
|
||||
writecommand(HX8357_MADCTL);
|
||||
writedata(0xC0);
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
|
||||
writecommand(HX8357_TEON); // TE off
|
||||
writedata(0x00);
|
||||
|
@ -4,22 +4,22 @@
|
||||
rotation = m % 4;
|
||||
switch (rotation) {
|
||||
case 0: // Portrait
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 1: // Landscape (Portrait + 90)
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
|
||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
case 2: // Inverter portrait
|
||||
writedata(TFT_MAD_RGB);
|
||||
writedata(TFT_MAD_COLOR_ORDER);
|
||||
_width = TFT_WIDTH;
|
||||
_height = TFT_HEIGHT;
|
||||
break;
|
||||
case 3: // Inverted landscape
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
|
||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||
_width = TFT_HEIGHT;
|
||||
_height = TFT_WIDTH;
|
||||
break;
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
#define HX8357D_DRIVER
|
||||
|
||||
// If green and blue swapped on display then change the RGB colour order
|
||||
// Only uncomment ONE of the following options
|
||||
#define TFT_RGB_ORDER TFT_RGB // Red-Green-Blue
|
||||
//#define TFT_RGB_ORDER TFT_BGR // 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
|
||||
|
Loading…
Reference in New Issue
Block a user