diff --git a/TFT_Drivers/R61581_Defines.h b/TFT_Drivers/R61581_Defines.h new file mode 100644 index 0000000..bd5fb88 --- /dev/null +++ b/TFT_Drivers/R61581_Defines.h @@ -0,0 +1,42 @@ +// Change the width and height if required (defined in portrait mode) +// or use the constructor to over-ride defaults +#define TFT_WIDTH 320 +#define TFT_HEIGHT 480 + + +// 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_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_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 diff --git a/TFT_Drivers/R61581_Init.h b/TFT_Drivers/R61581_Init.h new file mode 100644 index 0000000..929d680 --- /dev/null +++ b/TFT_Drivers/R61581_Init.h @@ -0,0 +1,80 @@ + +// This is the command sequence that initialises the R61581 driver +// +// This setup information uses simple 8 bit SPI writecommand() and writedata() functions +// +// See ST7735_Setup.h file for an alternative format + + +// Configure R61581 display + + writecommand(TFT_SLPOUT); + delay(20); + + writecommand(0xB0); + writedata(0x00); + + writecommand(0xD0); + writedata(0x07); + writedata(0x42); + writedata(0x18); + + writecommand(0xD1); + writedata(0x00); + writedata(0x07); + writedata(0x10); + + writecommand(0xD2); + writedata(0x01); + writedata(0x02); + + writecommand(0xC0); + writedata(0x12); + writedata(0x3B); + writedata(0x00); + writedata(0x02); + writedata(0x11); + + writecommand(0xC5); + writedata(0x03); + + writecommand(0xC8); + writedata(0x00); + writedata(0x32); + writedata(0x36); + writedata(0x45); + writedata(0x06); + writedata(0x16); + writedata(0x37); + writedata(0x75); + writedata(0x77); + writedata(0x54); + writedata(0x0C); + writedata(0x00); + + writecommand(TFT_MADCTL); + writedata(0x0A); + + writecommand(0x3A); + writedata(0x55); + + writecommand(TFT_CASET); + writedata(0x00); + writedata(0x00); + writedata(0x01); + writedata(0x3F); + + writecommand(TFT_PASET); + writedata(0x00); + writedata(0x00); + writedata(0x01); + writedata(0xDF); + + delay(120); + writecommand(TFT_DISPON); + + delay(25); +// End of R61581 display configuration + + + diff --git a/TFT_Drivers/R61581_Rotation.h b/TFT_Drivers/R61581_Rotation.h new file mode 100644 index 0000000..4d7dc61 --- /dev/null +++ b/TFT_Drivers/R61581_Rotation.h @@ -0,0 +1,27 @@ + // This is the command sequence that rotates the R61581 driver coordinate frame + + writecommand(TFT_MADCTL); + rotation = m % 4; + switch (rotation) { + case 0: // Portrait + writedata(TFT_MAD_BGR | TFT_MAD_MX); + _width = TFT_WIDTH; + _height = TFT_HEIGHT; + break; + case 1: // Landscape (Portrait + 90) + writedata(TFT_MAD_MV | TFT_MAD_BGR); + _width = TFT_HEIGHT; + _height = TFT_WIDTH; + break; + case 2: // Inverter portrait + writedata(TFT_MAD_BGR | TFT_MAD_GS); + _width = TFT_WIDTH; + _height = TFT_HEIGHT; + break; + case 3: // Inverted landscape + writedata(TFT_MAD_MV | TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_GS); + _width = TFT_HEIGHT; + _height = TFT_WIDTH; + break; + } + \ No newline at end of file diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index 92873da..0b9fc21 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -361,6 +361,9 @@ void TFT_eSPI::init(uint8_t tc) #elif defined (ST7789_DRIVER) #include "TFT_Drivers/ST7789_Init.h" +#elif defined (R61581_DRIVER) + #include "TFT_Drivers/R61581_Init.h" + #endif spi_end(); @@ -409,6 +412,9 @@ void TFT_eSPI::setRotation(uint8_t m) #elif defined (ST7789_DRIVER) #include "TFT_Drivers/ST7789_Rotation.h" +#elif defined (R61581_DRIVER) + #include "TFT_Drivers/R61581_Rotation.h" + #endif delayMicroseconds(10); diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 8f31f29..1dcb28c 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -330,7 +330,7 @@ SET_PERI_REG_MASK(SPI_CMD_REG(SPI_NUM), SPI_USR); \ while (READ_PERI_REG(SPI_CMD_REG(SPI_NUM))&SPI_USR); - // Write 16 bits (used for ESP32_PARALLEL or ILI9488_DRIVER) + // Write 16 bits #define tft_Write_16S(C) \ WRITE_PERI_REG(SPI_MOSI_DLEN_REG(SPI_NUM), 16-1); \ WRITE_PERI_REG(SPI_W0_REG(SPI_NUM), C); \ diff --git a/User_Setup.h b/User_Setup.h index 49107c0..5c48d70 100644 --- a/User_Setup.h +++ b/User_Setup.h @@ -25,6 +25,7 @@ //#define ILI9486_DRIVER //#define ILI9488_DRIVER //#define ST7789_DRIVER // Define the screen size below for this display +//#define R61581_DRIVER // Some displays support SPI reads via the MISO pin, if the display has a single // bi-directional SDA pin the library will try to use bit banging to read the line diff --git a/User_Setup_Select.h b/User_Setup_Select.h index bd31358..69d27a0 100644 --- a/User_Setup_Select.h +++ b/User_Setup_Select.h @@ -25,13 +25,14 @@ //#include // Setup file configured for my ST7735 //#include // Setup file configured for my ILI9163 //#include // Setup file configured for my S6D02A1 -//#include // Setup file configured for my stock RPi TFT -//#include // Setup file configured for my modified RPi TFT -//#include // Setup file configured for my ST7735 128x128 display -//#include // Setup file configured for my ILI9163 128x128 display -//#include // Setup file configured for my ST7735 -//#include // Setup file configured for ESP8266 and RPi TFT with touch -//#include // Setup file configured for ESP32 and RPi TFT with touch +//#include // Setup file configured for my stock RPi TFT +//#include // Setup file configured for my modified RPi TFT +//#include // Setup file configured for my ST7735 128x128 display +//#include // Setup file configured for my ILI9163 128x128 display +//#include // Setup file configured for my ST7735 +//#include // Setup file configured for ESP8266 and RPi TFT with touch + +//#include // Setup file configured for ESP32 and RPi TFT with touch //#include // Setup file for the ESP32 based M5Stack //#include // Setup file for the ESP32 with parallel bus TFT //#include // Setup file for the ESP32 with parallel bus TFT @@ -102,6 +103,9 @@ #elif defined (ST7789_DRIVER) #include "TFT_Drivers/ST7789_Defines.h" #define TFT_DRIVER 0x7789 +#elif defined (R61581_DRIVER) + #include "TFT_Drivers/R61581_Defines.h" + #define TFT_DRIVER 0x6158 #elif defined (XYZZY_DRIVER) // <<<<<<<<<<<<<<<<<<<<<<<< ADD NEW DRIVER HERE #include "TFT_Drivers/XYZZY_Defines.h" #define TFT_DRIVER 0x0000 diff --git a/User_Setups/SetupX_Template.h b/User_Setups/SetupX_Template.h index 3052b69..11cf2ab 100644 --- a/User_Setups/SetupX_Template.h +++ b/User_Setups/SetupX_Template.h @@ -25,6 +25,7 @@ //#define ILI9486_DRIVER //#define ILI9488_DRIVER //#define ST7789_DRIVER // Define the screen size below for this display +//#define R61581_DRIVER // Some displays support SPI reads via the MISO pin, if the display has a single // bi-directional SDA pin the library will try to use bit banging to read the line diff --git a/library.json b/library.json index 94d5340..83de892 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "1.3.4", + "version": "1.3.5", "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": diff --git a/library.properties b/library.properties index b8b5f01..9f33bfb 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=1.3.4 +version=1.3.5 author=Bodmer maintainer=Bodmer sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE