mirror of
https://github.com/Bodmer/TFT_eSPI.git
synced 2025-08-02 20:24:41 +02:00
Add option for different RGB colour order with ST7789
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display //#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue //#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
This commit is contained in:
@@ -45,6 +45,20 @@
|
|||||||
#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
|
||||||
|
#ifdef CGRAM_OFFSET
|
||||||
|
#define TFT_MAD_COLOR_ORDER TFT_MAD_BGR
|
||||||
|
#else
|
||||||
|
#define TFT_MAD_COLOR_ORDER TFT_MAD_RGB
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
|
||||||
|
|
||||||
// ST7789 specific commands used in init
|
// ST7789 specific commands used in init
|
||||||
|
@@ -14,12 +14,7 @@
|
|||||||
//------------------------------display and color format setting--------------------------------//
|
//------------------------------display and color format setting--------------------------------//
|
||||||
writecommand(ST7789_MADCTL);
|
writecommand(ST7789_MADCTL);
|
||||||
writedata(0x00);
|
writedata(0x00);
|
||||||
#ifdef CGRAM_OFFSET
|
writedata(TFT_MAD_COLOR_ORDER);
|
||||||
writedata(0x48); // BGR colour order for 240 x 240 TFT
|
|
||||||
#else
|
|
||||||
writedata(0x40); // RGB colour order for 240 x 320 TFT (Issue #232)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// JLX240 display datasheet
|
// JLX240 display datasheet
|
||||||
writecommand(0xB6);
|
writecommand(0xB6);
|
||||||
|
@@ -5,47 +5,43 @@
|
|||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case 0: // Portrait
|
case 0: // Portrait
|
||||||
#ifdef CGRAM_OFFSET
|
#ifdef CGRAM_OFFSET
|
||||||
writedata(TFT_MAD_BGR);
|
|
||||||
colstart = 0;
|
colstart = 0;
|
||||||
rowstart = 0;
|
rowstart = 0;
|
||||||
#else
|
|
||||||
writedata(TFT_MAD_RGB);
|
|
||||||
#endif
|
#endif
|
||||||
|
writedata(TFT_MAD_COLOR_ORDER);
|
||||||
|
|
||||||
_width = _init_width;
|
_width = _init_width;
|
||||||
_height = _init_height;
|
_height = _init_height;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // Landscape (Portrait + 90)
|
case 1: // Landscape (Portrait + 90)
|
||||||
#ifdef CGRAM_OFFSET
|
#ifdef CGRAM_OFFSET
|
||||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR);
|
|
||||||
colstart = 0;
|
colstart = 0;
|
||||||
rowstart = 0;
|
rowstart = 0;
|
||||||
#else
|
|
||||||
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
|
|
||||||
#endif
|
#endif
|
||||||
|
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);
|
||||||
|
|
||||||
_width = _init_height;
|
_width = _init_height;
|
||||||
_height = _init_width;
|
_height = _init_width;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // Inverter portrait
|
case 2: // Inverter portrait
|
||||||
#ifdef CGRAM_OFFSET
|
#ifdef CGRAM_OFFSET
|
||||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR);
|
|
||||||
colstart = 0;
|
colstart = 0;
|
||||||
rowstart = 80;
|
rowstart = 80;
|
||||||
#else
|
|
||||||
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
|
|
||||||
#endif
|
#endif
|
||||||
|
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||||
|
|
||||||
_width = _init_width;
|
_width = _init_width;
|
||||||
_height = _init_height;
|
_height = _init_height;
|
||||||
break;
|
break;
|
||||||
case 3: // Inverted landscape
|
case 3: // Inverted landscape
|
||||||
#ifdef CGRAM_OFFSET
|
#ifdef CGRAM_OFFSET
|
||||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR);
|
|
||||||
colstart = 80;
|
colstart = 80;
|
||||||
rowstart = 0;
|
rowstart = 0;
|
||||||
#else
|
|
||||||
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
|
|
||||||
#endif
|
#endif
|
||||||
|
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);
|
||||||
|
|
||||||
_width = _init_height;
|
_width = _init_height;
|
||||||
_height = _init_width;
|
_height = _init_width;
|
||||||
break;
|
break;
|
||||||
|
@@ -29,6 +29,10 @@
|
|||||||
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||||
//#define M5STACK
|
//#define M5STACK
|
||||||
|
|
||||||
|
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on 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 ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
// For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
|
||||||
// #define TFT_WIDTH 80
|
// #define TFT_WIDTH 80
|
||||||
// #define TFT_WIDTH 128
|
// #define TFT_WIDTH 128
|
||||||
|
@@ -60,6 +60,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// Identical looking TFT displays may have a different colour ordering in the 16 bit colour
|
||||||
|
#define TFT_BGR 0 // Colour order Blue-Green-Red
|
||||||
|
#define TFT_RGB 1 // Colour order Red-Green-Blue
|
||||||
|
|
||||||
|
|
||||||
// Load the right driver definition - do not tinker here !
|
// Load the right driver definition - do not tinker here !
|
||||||
#if defined (ILI9341_DRIVER)
|
#if defined (ILI9341_DRIVER)
|
||||||
#include <TFT_Drivers/ILI9341_Defines.h>
|
#include <TFT_Drivers/ILI9341_Defines.h>
|
||||||
@@ -101,6 +106,7 @@
|
|||||||
#define TFT_DRIVER 0x0000
|
#define TFT_DRIVER 0x0000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// These are the pins for all ESP8266 boards
|
// These are the pins for all ESP8266 boards
|
||||||
// Name GPIO Function
|
// Name GPIO Function
|
||||||
#define PIN_D0 16 // WAKE
|
#define PIN_D0 16 // WAKE
|
||||||
|
@@ -26,6 +26,11 @@
|
|||||||
//#define ILI9488_DRIVER
|
//#define ILI9488_DRIVER
|
||||||
//#define ST7789_DRIVER // Define the screen size below for this display
|
//#define ST7789_DRIVER // Define the screen size below for this display
|
||||||
|
|
||||||
|
// For ST7789 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 M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
|
||||||
//#define M5STACK
|
//#define M5STACK
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TFT_eSPI",
|
"name": "TFT_eSPI",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
|
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
|
||||||
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
|
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
|
||||||
"repository":
|
"repository":
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
name=TFT_eSPI
|
name=TFT_eSPI
|
||||||
version=1.2.1
|
version=1.2.2
|
||||||
author=Bodmer
|
author=Bodmer
|
||||||
maintainer=Bodmer
|
maintainer=Bodmer
|
||||||
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
|
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
|
||||||
|
Reference in New Issue
Block a user