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:
Bodmer 2022-03-12 20:04:41 +00:00
parent 39b0d6ab9a
commit 31b2de56c1
4 changed files with 19 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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