From 90189130ec85a3cbcd5ce60170358a40a04c0107 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Wed, 31 Jul 2019 01:07:05 +0100 Subject: [PATCH] Update for #379 Added support for ST7789 135 x 240 display which needs offsets Added Setup135_ST7789.h as an example setup file for ESP8266 --- TFT_Drivers/ST7789_Rotation.h | 48 +++++++++++++++++++++++++----- User_Setup_Select.h | 4 ++- User_Setups/Setup135_ST7789.h | 56 +++++++++++++++++++++++++++++++++++ library.json | 2 +- library.properties | 2 +- 5 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 User_Setups/Setup135_ST7789.h diff --git a/TFT_Drivers/ST7789_Rotation.h b/TFT_Drivers/ST7789_Rotation.h index d490279c..707c7757 100644 --- a/TFT_Drivers/ST7789_Rotation.h +++ b/TFT_Drivers/ST7789_Rotation.h @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/User_Setup_Select.h b/User_Setup_Select.h index aae87cdd..413f22b1 100644 --- a/User_Setup_Select.h +++ b/User_Setup_Select.h @@ -50,7 +50,9 @@ //#include // Setup file for ESP32 and TTGO TM ST7789 SPI bus TFT //#include // Setup file configured for ST7789 240 x 240 -//#include // Setup file configured for my ST7735S 80x160 +//#include // Setup file configured for my ST7735S 80x160 + +//#include // Setup file for ESP8266 and ST7789 125 x 240 TFT //#include diff --git a/User_Setups/Setup135_ST7789.h b/User_Setups/Setup135_ST7789.h new file mode 100644 index 00000000..e87abad7 --- /dev/null +++ b/User_Setups/Setup135_ST7789.h @@ -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 \ No newline at end of file diff --git a/library.json b/library.json index 203187d3..01341707 100644 --- a/library.json +++ b/library.json @@ -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": diff --git a/library.properties b/library.properties index 9c964bb2..3be6902d 100644 --- a/library.properties +++ b/library.properties @@ -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