Skip to content

Commit

Permalink
Update for WROVER to address #232
Browse files Browse the repository at this point in the history
The library supported 240x240 ST7789 displays only which require an 80
pixel offset in rotation 2 and 3
The library now also supports the 240x320 display which has a different
RGB colour order.
  • Loading branch information
Bodmer committed Nov 6, 2018
1 parent 8d29c39 commit cbc2e66
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 45 deletions.
4 changes: 3 additions & 1 deletion TFT_Drivers/ST7789_Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#define TFT_HEIGHT 320
#endif

#define CGRAM_OFFSET
#if (TFT_HEIGHT == 240) && (TFT_WIDTH == 240)
#define CGRAM_OFFSET
#endif

// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
Expand Down
9 changes: 8 additions & 1 deletion TFT_Drivers/ST7789_Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
//------------------------------display and color format setting--------------------------------//
writecommand(ST7789_MADCTL);
writedata(0x00);
writedata(0x48);
#ifdef CGRAM_OFFSET
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
writecommand(0xB6);
Expand Down Expand Up @@ -114,7 +119,9 @@

writecommand(ST7789_DISPON); //Display on

#ifdef TFT_BL
// Turn on the back-light LED
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_BL, OUTPUT);
#endif
}
26 changes: 17 additions & 9 deletions TFT_Drivers/ST7789_Rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,36 @@
writedata(TFT_MAD_RGB);
_width = _init_width;
_height = _init_height;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
_width = _init_height;
_height = _init_width;
colstart = 0;
rowstart = 0;
break;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
#endif
break;
case 2: // Inverter portrait
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
_width = _init_width;
_height = _init_height;
colstart = 0;
rowstart = 80;
break;
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 80;
#endif
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
_width = _init_height;
_height = _init_width;
colstart = 80;
rowstart = 0;
break;
#ifdef CGRAM_OFFSET
colstart = 80;
rowstart = 0;
#endif
break;
}
23 changes: 15 additions & 8 deletions User_Setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@
//#define ILI9481_DRIVER
//#define ILI9486_DRIVER
//#define ILI9488_DRIVER
//#define ST7789_DRIVER
//#define ST7789_DRIVER // Define the screen size below for this display

// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
//#define M5STACK

// For 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 128
// #define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
// #define TFT_HEIGHT 160
//#define TFT_HEIGHT 128
// #define TFT_HEIGHT 128
// #define TFT_HEIGHT 240 // ST7789 240 x 240
// #define TFT_HEIGHT 320 // ST7789 240 x 320

// For ST7735 ONLY, define the type of display, originally this was based on the
// colour of the tab on the screen protector film but this is not always true, so try
Expand All @@ -46,10 +49,10 @@
// #define ST7735_GREENTAB
// #define ST7735_GREENTAB2
// #define ST7735_GREENTAB3
// #define ST7735_GREENTAB128 // For 128 x 128 display
// #define ST7735_GREENTAB128 // For 128 x 128 display
// #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
// #define ST7735_REDTAB
//#define ST7735_BLACKTAB
// #define ST7735_BLACKTAB

// ##################################################################################
//
Expand Down Expand Up @@ -94,7 +97,9 @@
#define TFT_CS PIN_D8 // Chip select control pin D8
#define TFT_DC PIN_D3 // Data Command control pin
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V

//#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)

//#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen

Expand Down Expand Up @@ -124,10 +129,12 @@
//#define TFT_MISO 19
//#define TFT_MOSI 23
//#define TFT_SCLK 18
//#define TFT_CS 15 // Chip select control pin
//#define TFT_CS 15 // Chip select control pin
//#define TFT_DC 2 // Data Command control pin
//#define TFT_RST 4 // Reset pin (could connect to RST pin)
//#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
//#define TFT_BL 32 // LED back-light (only for ST7789 with backlight control pin)


// For the M5Stack module use these #define lines
//#define TFT_MISO 19
Expand All @@ -136,7 +143,7 @@
//#define TFT_CS 14 // Chip select control pin
//#define TFT_DC 27 // Data Command control pin
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
//#define TFT_BL 32 // LED back-light
//#define TFT_BL 32 // LED back-light (required for M5Stack)

//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen

Expand Down
91 changes: 67 additions & 24 deletions User_Setups/SetupX_Template.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
// If this file is edited correctly then all the library example sketches should
// run without the need to make any more changes for a particular hardware setup!
// Note that some sketches are designed for a particular TFT pixel width/height

// ##################################################################################
//
Expand All @@ -19,15 +20,23 @@
//#define ILI9163_DRIVER
//#define S6D02A1_DRIVER
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
//#define HX8357D_DRIVER
//#define ILI9481_DRIVER
//#define ILI9486_DRIVER
//#define ILI9488_DRIVER
//#define ST7789_DRIVER // Define the screen size below for this display

// For M5Stack ESP32 module with integrated display ONLY, remove // in line below
//#define M5STACK

// For ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
//#define TFT_WIDTH 80
//#define TFT_WIDTH 128
//#define TFT_HEIGHT 160
//#define TFT_HEIGHT 128
// For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
// #define TFT_WIDTH 80
// #define TFT_WIDTH 128
// #define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
// #define TFT_HEIGHT 160
// #define TFT_HEIGHT 128
// #define TFT_HEIGHT 240 // ST7789 240 x 240
// #define TFT_HEIGHT 320 // ST7789 240 x 320

// For ST7735 ONLY, define the type of display, originally this was based on the
// colour of the tab on the screen protector film but this is not always true, so try
Expand All @@ -36,14 +45,14 @@
// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this
// this User_Setup file, then rebuild and upload the sketch to the board again:

//#define ST7735_INITB
//#define ST7735_GREENTAB
//#define ST7735_GREENTAB2
//#define ST7735_GREENTAB3
//#define ST7735_GREENTAB128 // For 128 x 128 display
//#define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
//#define ST7735_REDTAB
//#define ST7735_BLACKTAB
// #define ST7735_INITB
// #define ST7735_GREENTAB
// #define ST7735_GREENTAB2
// #define ST7735_GREENTAB3
// #define ST7735_GREENTAB128 // For 128 x 128 display
// #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
// #define ST7735_REDTAB
// #define ST7735_BLACKTAB

// ##################################################################################
//
Expand Down Expand Up @@ -88,9 +97,11 @@
#define TFT_CS PIN_D8 // Chip select control pin D8
#define TFT_DC PIN_D3 // Data Command control pin
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V

//#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)

//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen
//#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen

//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only

Expand Down Expand Up @@ -118,14 +129,12 @@
//#define TFT_MISO 19
//#define TFT_MOSI 23
//#define TFT_SCLK 18
//#define TFT_CS 15 // Chip select control pin
//#define TFT_CS 15 // Chip select control pin
//#define TFT_DC 2 // Data Command control pin
//#define TFT_RST 4 // Reset pin (could connect to RST pin)
//#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST
//#define TFT_BL 32 // LED back-light (only for ST7789 with backlight control pin)

//#define TOUCH_CS 22 // Chip select pin (T_CS) of touch screen

//#define TFT_WR 21 // Write strobe for modified Raspberry Pi TFT only

// For the M5Stack module use these #define lines
//#define TFT_MISO 19
Expand All @@ -134,8 +143,40 @@
//#define TFT_CS 14 // Chip select control pin
//#define TFT_DC 27 // Data Command control pin
//#define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin)
//#define TFT_BL 32 // LED back-light
//#define TFT_BL 32 // LED back-light (required for M5Stack)

//#define TOUCH_CS 21 // Chip select pin (T_CS) of touch screen

//#define TFT_WR 22 // Write strobe for modified Raspberry Pi TFT only

// ###### EDIT THE PINs BELOW TO SUIT YOUR ESP32 PARALLEL TFT SETUP ######

// The library supports 8 bit parallel TFTs with the ESP32, the pin
// selection below is compatible with ESP32 boards in UNO format.
// Wemos D32 boards need to be modified, see diagram in Tools folder.
// Only ILI9481 and ILI9341 based displays have been tested!

// Parallel bus is only supported on ESP32
// Uncomment line below to use ESP32 Parallel interface instead of SPI

//#define ESP32_PARALLEL

// The ESP32 and TFT the pins used for testing are:
//#define TFT_CS 33 // Chip select control pin (library pulls permanently low
//#define TFT_DC 15 // Data Command control pin - use a pin in the range 0-31
//#define TFT_RST 32 // Reset pin, toggles on startup

//#define TFT_WR 4 // Write strobe control pin - use a pin in the range 0-31
//#define TFT_RD 2 // Read strobe control pin - use a pin in the range 0-31

//#define TFT_D0 12 // Must use pins in the range 0-31 for the data bus
//#define TFT_D1 13 // so a single register write sets/clears all bits.
//#define TFT_D2 26 // Pins can be randomly assigned, this does not affect
//#define TFT_D3 25 // TFT screen update performance.
//#define TFT_D4 17
//#define TFT_D5 16
//#define TFT_D6 27
//#define TFT_D7 14

// ##################################################################################
//
Expand Down Expand Up @@ -167,9 +208,9 @@
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
Expand Down Expand Up @@ -202,9 +243,11 @@
// #define SPI_FREQUENCY 20000000
#define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3
// #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS
// #define SPI_FREQUENCY 53400000
// #define SPI_FREQUENCY 80000000

// Optional reduced SPI frequency for reading TFT
#define SPI_READ_FREQUENCY 20000000

// The XPT2046 requires a lower SPI clock rate of 2.5MHz so we define that here:
#define SPI_TOUCH_FREQUENCY 2500000

Expand All @@ -219,4 +262,4 @@
// Transactions are automatically enabled by the library for an ESP32 (to use HAL mutex)
// so changing it here has no effect

// #define SUPPORT_TRANSACTIONS
//#define SUPPORT_TRANSACTIONS
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TFT_eSPI",
"version": "1.1.2",
"version": "1.1.3",
"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",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TFT_eSPI
version=1.1.2
version=1.1.3
author=Bodmer
maintainer=Bodmer
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
Expand Down

0 comments on commit cbc2e66

Please sign in to comment.