Commit 53119823 authored by Bodmer's avatar Bodmer

Add support for ST7789 display (240 x 240)

parent 43abc3b9
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 240
#define TFT_HEIGHT 240
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_NORON 0x13
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_CASET 0x2A
#define TFT_PASET 0x2B
#define TFT_RAMWR 0x2C
#define TFT_RAMRD 0x2E
#define TFT_MADCTL 0x36
#define TFT_COLMOD 0x3A
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
#define TFT_MAD_MH 0x04
#define TFT_MAD_SS 0x02
#define TFT_MAD_GS 0x01
#define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read
// This is the command sequence that initialises the ST7789 driver
// Configure ST7789 display
{
static const uint8_t PROGMEM
st7789[] = {
9,
TFT_SWRST, TFT_INIT_DELAY, 150,
TFT_SLPOUT, TFT_INIT_DELAY, 255,
TFT_COLMOD, 1+TFT_INIT_DELAY, 0x55, 10,
TFT_MADCTL, 1, 0x00,
TFT_CASET, 4, 0x00, 0x00, 0x00, 0xF0,
TFT_PASET, 4, 0x00, 0x00, 0x00, 0xF0,
TFT_INVON, TFT_INIT_DELAY, 10,
TFT_NORON, TFT_INIT_DELAY, 10,
TFT_DISPON, TFT_INIT_DELAY, 255
};
commandList(st7789);
}
// End of ST7789 display configuration
// This is the command sequence that rotates the ST7789 driver coordinate frame
writecommand(TFT_MADCTL);
rotation = m % 4;
switch (rotation) {
case 0: // Portrait
writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 1: // Landscape (Portrait + 90)
writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
case 2: // Inverter portrait
writedata(TFT_MAD_RGB);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
break;
case 3: // Inverted landscape
writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
break;
}
...@@ -331,6 +331,9 @@ void TFT_eSPI::init(uint8_t tc) ...@@ -331,6 +331,9 @@ void TFT_eSPI::init(uint8_t tc)
#elif defined (HX8357D_DRIVER) #elif defined (HX8357D_DRIVER)
#include "TFT_Drivers/HX8357D_Init.h" #include "TFT_Drivers/HX8357D_Init.h"
#elif defined (ST7789_DRIVER)
#include "TFT_Drivers/ST7789_Init.h"
#endif #endif
spi_end(); spi_end();
...@@ -375,6 +378,9 @@ void TFT_eSPI::setRotation(uint8_t m) ...@@ -375,6 +378,9 @@ void TFT_eSPI::setRotation(uint8_t m)
#elif defined (HX8357D_DRIVER) #elif defined (HX8357D_DRIVER)
#include "TFT_Drivers/HX8357D_Rotation.h" #include "TFT_Drivers/HX8357D_Rotation.h"
#elif defined (ST7789_DRIVER)
#include "TFT_Drivers/ST7789_Rotation.h"
#endif #endif
delayMicroseconds(10); delayMicroseconds(10);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
//#define HX8357D_DRIVER //#define HX8357D_DRIVER
//#define ILI9481_DRIVER //#define ILI9481_DRIVER
//#define ILI9488_DRIVER //#define ILI9488_DRIVER
//#define ST7789_DRIVER
// 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
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
//#include <User_Setups/Setup15_HX8357D.h> // Setup file configured for HX8357D (untested) //#include <User_Setups/Setup15_HX8357D.h> // Setup file configured for HX8357D (untested)
//#include <User_Setups/Setup16_ILI9488_Parallel.h> // Setup file for the ESP32 with parallel bus TFT //#include <User_Setups/Setup16_ILI9488_Parallel.h> // Setup file for the ESP32 with parallel bus TFT
//#include <User_Setups/Setup17_ePaper.h> // Setup file for any Waveshare ePaper display //#include <User_Setups/Setup17_ePaper.h> // Setup file for any Waveshare ePaper display
//#include <User_Setups/Setup18_ST7789.h> // Setup file configured for HX8357D (untested)
//#include <User_Setups/SetupX_Template.h> //#include <User_Setups/SetupX_Template.h>
...@@ -82,6 +83,9 @@ ...@@ -82,6 +83,9 @@
#elif defined (EPD_DRIVER) #elif defined (EPD_DRIVER)
#include "TFT_Drivers/EPD_Defines.h" #include "TFT_Drivers/EPD_Defines.h"
#define TFT_DRIVER 0xE9D #define TFT_DRIVER 0xE9D
#elif defined (ST7789_DRIVER)
#include "TFT_Drivers/ST7789_Defines.h"
#define TFT_DRIVER 0x7789
#elif defined (XYZZY_DRIVER) // <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE #elif defined (XYZZY_DRIVER) // <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE
#include "TFT_Drivers/XYZZY_Defines.h" #include "TFT_Drivers/XYZZY_Defines.h"
#define TFT_DRIVER 0x0000 #define TFT_DRIVER 0x0000
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment