mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-07-31 11:17:32 +02: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:
@@ -39,6 +39,16 @@
|
|||||||
#define TFT_MAD_SS 0x02
|
#define TFT_MAD_SS 0x02
|
||||||
#define TFT_MAD_GS 0x01
|
#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
|
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||||
|
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@
|
|||||||
writedata(0x55); // 16 bit
|
writedata(0x55); // 16 bit
|
||||||
|
|
||||||
writecommand(HX8357_MADCTL);
|
writecommand(HX8357_MADCTL);
|
||||||
writedata(0xC0);
|
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||||
|
|
||||||
writecommand(HX8357_TEON); // TE off
|
writecommand(HX8357_TEON); // TE off
|
||||||
writedata(0x00);
|
writedata(0x00);
|
||||||
|
@@ -4,22 +4,22 @@
|
|||||||
rotation = m % 4;
|
rotation = m % 4;
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case 0: // Portrait
|
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;
|
_width = TFT_WIDTH;
|
||||||
_height = TFT_HEIGHT;
|
_height = TFT_HEIGHT;
|
||||||
break;
|
break;
|
||||||
case 1: // Landscape (Portrait + 90)
|
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;
|
_width = TFT_HEIGHT;
|
||||||
_height = TFT_WIDTH;
|
_height = TFT_WIDTH;
|
||||||
break;
|
break;
|
||||||
case 2: // Inverter portrait
|
case 2: // Inverter portrait
|
||||||
writedata(TFT_MAD_RGB);
|
writedata(TFT_MAD_COLOR_ORDER);
|
||||||
_width = TFT_WIDTH;
|
_width = TFT_WIDTH;
|
||||||
_height = TFT_HEIGHT;
|
_height = TFT_HEIGHT;
|
||||||
break;
|
break;
|
||||||
case 3: // Inverted landscape
|
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;
|
_width = TFT_HEIGHT;
|
||||||
_height = TFT_WIDTH;
|
_height = TFT_WIDTH;
|
||||||
break;
|
break;
|
||||||
|
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#define HX8357D_DRIVER
|
#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
|
// 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
|
#define TFT_CS PIN_D8 // Chip select control pin D8
|
||||||
|
Reference in New Issue
Block a user