Skip to content

Commit

Permalink
Update for #379
Browse files Browse the repository at this point in the history
Added support for ST7789 135 x 240 display which needs offsets
Added Setup135_ST7789.h as an example setup file for ESP8266
  • Loading branch information
Bodmer committed Jul 31, 2019
1 parent 4a38aa6 commit 9018913
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 11 deletions.
48 changes: 40 additions & 8 deletions TFT_Drivers/ST7789_Rotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
switch (rotation) {
case 0: // Portrait
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
if (_init_width == 135)
{
colstart = 52;
rowstart = 40;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_COLOR_ORDER);

Expand All @@ -16,8 +24,16 @@

case 1: // Landscape (Portrait + 90)
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 0;
if (_init_width == 135)
{
colstart = 40;
rowstart = 53;
}
else
{
colstart = 0;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER);

Expand All @@ -27,8 +43,16 @@

case 2: // Inverter portrait
#ifdef CGRAM_OFFSET
colstart = 0;
rowstart = 80;
if (_init_width == 135)
{
colstart = 53;
rowstart = 40;
}
else
{
colstart = 0;
rowstart = 80;
}
#endif
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);

Expand All @@ -37,8 +61,16 @@
break;
case 3: // Inverted landscape
#ifdef CGRAM_OFFSET
colstart = 80;
rowstart = 0;
if (_init_width == 135)
{
colstart = 40;
rowstart = 52;
}
else
{
colstart = 80;
rowstart = 0;
}
#endif
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER);

Expand Down
4 changes: 3 additions & 1 deletion User_Setup_Select.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
//#include <User_Setups/Setup23_TTGO_TM.h> // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT
//#include <User_Setups/Setup24_ST7789.h> // Setup file configured for ST7789 240 x 240

//#include <User_Setups/Setup43_ST7735.h> // Setup file configured for my ST7735S 80x160
//#include <User_Setups/Setup43_ST7735.h> // Setup file configured for my ST7735S 80x160

//#include <User_Setups/Setup135_ST7789.h> // Setup file for ESP8266 and ST7789 125 x 240 TFT

//#include <User_Setups/SetupX_Template.h>

Expand Down
56 changes: 56 additions & 0 deletions User_Setups/Setup135_ST7789.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ST7789 135 x 240 display with no chip select line

#define ST7789_DRIVER // Configure all registers

#define TFT_WIDTH 135
#define TFT_HEIGHT 240

#define CGRAM_OFFSET // Library will add offsets required

//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red

//#define TFT_INVERSION_ON
//#define TFT_INVERSION_OFF

// DSTIKE stepup
//#define TFT_DC 23
//#define TFT_RST 32
//#define TFT_MOSI 26
//#define TFT_SCLK 27

// Generic ESP32 setup
//#define TFT_MISO 19
//#define TFT_MOSI 23
//#define TFT_SCLK 18
//#define TFT_CS -1 // Not connected
//#define TFT_DC 2
//#define TFT_RST 4 // Connect reset to ensure display initialises

// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
#define TFT_CS -1 // Define as not used
#define TFT_DC PIN_D1 // Data Command control pin
//#define TFT_RST PIN_D4 // TFT reset pin (could connect to NodeMCU RST, see next line)
#define TFT_RST -1 // TFT reset pin connect to NodeMCU RST, must also then add 10K pull down to TFT SCK


#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#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_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

#define SMOOTH_FONT


// #define SPI_FREQUENCY 27000000
#define SPI_FREQUENCY 40000000

#define SPI_READ_FREQUENCY 20000000

#define SPI_TOUCH_FREQUENCY 2500000

// #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.4.15",
"version": "1.4.16",
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
"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.4.15
version=1.4.16
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 9018913

Please sign in to comment.