diff --git a/TFT_Drivers/ST7735_Defines.h b/TFT_Drivers/ST7735_Defines.h index 61434b6..6b17e72 100644 --- a/TFT_Drivers/ST7735_Defines.h +++ b/TFT_Drivers/ST7735_Defines.h @@ -14,6 +14,7 @@ #define INITR_BLACKTAB 0x2 #define INITR_GREENTAB2 0x3 // Use if you get random pixels on two edges of green tab display #define INITR_GREENTAB3 0x4 // Use if you get random pixels on edge(s) of 128x128 screen +#define INITR_GREENTAB128 0x5 // Use if you only get part of 128x128 screen in rotation 0 & 1 #define INITB 0xB @@ -23,13 +24,20 @@ #elif defined (ST7735_GREENTAB) #define TAB_COLOUR INITR_GREENTAB + #define CGRAM_OFFSET #elif defined (ST7735_GREENTAB2) #define TAB_COLOUR INITR_GREENTAB2 + #define CGRAM_OFFSET #elif defined (ST7735_GREENTAB3) #define TAB_COLOUR INITR_GREENTAB3 + #define CGRAM_OFFSET +#elif defined (ST7735_GREENTAB128) + #define TAB_COLOUR INITR_GREENTAB128 + #define CGRAM_OFFSET + #elif defined (ST6635_REDTAB) #define TAB_COLOUR INITR_REDTAB diff --git a/TFT_Drivers/ST7735_Init.h b/TFT_Drivers/ST7735_Init.h index 6bbf3d5..549ea31 100644 --- a/TFT_Drivers/ST7735_Init.h +++ b/TFT_Drivers/ST7735_Init.h @@ -169,6 +169,12 @@ colstart = 2; rowstart = 3; } + else if (tabcolor == INITR_GREENTAB128) + { + commandList(Rcmd2green); + colstart = 0; + rowstart = 32; + } else if (tabcolor == INITR_REDTAB) { commandList(Rcmd2red); diff --git a/TFT_Drivers/ST7735_Rotation.h b/TFT_Drivers/ST7735_Rotation.h index dceea31..36a1066 100644 --- a/TFT_Drivers/ST7735_Rotation.h +++ b/TFT_Drivers/ST7735_Rotation.h @@ -16,6 +16,10 @@ writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); colstart = 2; rowstart = 3; + } else if(tabcolor == INITR_GREENTAB128) { + writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MH | TFT_MAD_BGR); + colstart = 0; + rowstart = 32; } else { writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); } @@ -33,7 +37,11 @@ writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); colstart = 3; rowstart = 2; - } else { + } else if(tabcolor == INITR_GREENTAB128) { + writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR); + colstart = 32; + rowstart = 0; + } else { writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); } _width = TFT_HEIGHT; @@ -50,7 +58,11 @@ writedata(TFT_MAD_BGR); colstart = 2; rowstart = 1; - } else { + } else if(tabcolor == INITR_GREENTAB128) { + writedata(TFT_MAD_BGR); + colstart = 0; + rowstart = 0; + } else { writedata(TFT_MAD_BGR); } _width = TFT_WIDTH; @@ -67,6 +79,10 @@ writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); colstart = 1; rowstart = 2; + } else if(tabcolor == INITR_GREENTAB128) { + writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); + colstart = 0; + rowstart = 0; } else { writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); } diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index ea28212..dcae74a 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -151,12 +151,12 @@ void TFT_eSPI::begin(void) void TFT_eSPI::init(void) { #ifdef TFT_CS - csport = portOutputRegister(digitalPinToPort(TFT_CS)); + //csport = portOutputRegister(digitalPinToPort(TFT_CS)); cspinmask = (uint32_t) digitalPinToBitMask(TFT_CS); #endif #ifdef TFT_DC - dcport = portOutputRegister(digitalPinToPort(TFT_DC)); + //dcport = portOutputRegister(digitalPinToPort(TFT_DC)); dcpinmask = (uint32_t) digitalPinToBitMask(TFT_DC); #endif @@ -1476,7 +1476,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t addr_col = 0xFFFF; addr_row = 0xFFFF; -#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) +#ifdef CGRAM_OFFSET xs+=colstart; xe+=colstart; ys+=rowstart; @@ -1504,21 +1504,6 @@ inline void TFT_eSPI::setAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t SPI1CMD |= SPIBUSY; while(SPI1CMD & SPIBUSY) {} - // This proves we can only change the byte level bit SPI register read-out order, not the actual byte order - // So we can't use this method to avoid coordinate byte order swapping! - //uint32_t x = (xs << 16) | xe; - // Swap bits in 32 bit word end for end - //x = (((x & 0xAAAAAAAA) >> 1) | ((x & 0x55555555) << 1)); - //x = (((x & 0xCCCCCCCC) >> 2) | ((x & 0x33333333) << 2)); - //x = (((x & 0xF0F0F0F0) >> 4) | ((x & 0x0F0F0F0F) << 4)); - //x = (((x & 0xFF00FF00) >> 8) | ((x & 0x00FF00FF) << 8)); - //x = (x >> 16) | (x << 16); - //SPI1W0 = x; - //SPI1C |= (SPICWBO | SPICRBO); // LSB first - //SPI1CMD |= SPIBUSY; - //while(SPI1CMD & SPIBUSY) {} - //SPI1C &= ~(SPICWBO | SPICRBO); // MSB first = default - // Row addr set DC_C; @@ -1690,7 +1675,7 @@ inline void TFT_eSPI::setAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t addr_col = 0xFFFF; addr_row = 0xFFFF; -#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) +#ifdef CGRAM_OFFSET x0+=colstart; x1+=colstart; y0+=rowstart; @@ -1746,7 +1731,7 @@ void TFT_eSPI::readAddrWindow(int32_t xs, int32_t ys, int32_t xe, int32_t ye) addr_col = 0xFFFF; addr_row = 0xFFFF; -#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) +#ifdef CGRAM_OFFSET xs+=colstart; xe+=colstart; ys+=rowstart; @@ -1812,7 +1797,7 @@ void TFT_eSPI::readAddrWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1) addr_col = 0xFFFF; addr_row = 0xFFFF; -#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) +#ifdef CGRAM_OFFSET x0+=colstart; x1+=colstart; y0+=rowstart; @@ -1861,7 +1846,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color) // Faster range checking, possible because x and y are unsigned if ((x >= _width) || (y >= _height)) return; -#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) +#ifdef CGRAM_OFFSET x+=colstart; y+=rowstart; #endif @@ -2043,7 +2028,7 @@ void TFT_eSPI::drawPixel(uint32_t x, uint32_t y, uint32_t color) if ((x >= _width) || (y >= _height)) return; spi_begin(); -#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) +#ifdef CGRAM_OFFSET x+=colstart; y+=rowstart; #endif diff --git a/User_Setup.h b/User_Setup.h index af89cbe..9a7955c 100644 --- a/User_Setup.h +++ b/User_Setup.h @@ -31,6 +31,7 @@ //#define ST7735_GREENTAB //#define ST7735_GREENTAB2 //#define ST7735_GREENTAB3 +//#define ST7735_GREENTAB128 // For 128 x 128 display //#define ST7735_REDTAB //#define ST7735_BLACKTAB @@ -52,7 +53,7 @@ // Display LED to NodeMCU pin VIN (or 5V, see below) // Display SCK to NodeMCU pin D5 // Display SDI/MOSI to NodeMCU pin D7 -// Display DC (or AO)to NodeMCU pin D3 +// Display DC (RS/AO)to NodeMCU pin D3 // Display RESET to NodeMCU pin D4 (or RST, see below) // Display CS to NodeMCU pin D8 (or GND, see below) // Display GND to NodeMCU pin GND (0V) @@ -60,6 +61,8 @@ // // The TFT RESET pin can be connected to the NodeMCU RST pin or 3.3V to free up a control pin // +// The DC (Data Command) pin may be labell AO or RS (Register Select) +// // With some displays such as the ILI9341 the TFT CS pin can be connected to GND if no more // SPI deivces (e.g. an SD Card) are connected, in this case comment out the #define TFT_CS // line below so it is NOT defined. Other displays such at the ST7735 require the TFT CS pin @@ -146,8 +149,8 @@ // #define SPI_FREQUENCY 5000000 // #define SPI_FREQUENCY 10000000 // #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 27000000 // Actually sets it to 26.67MHz = 80/3 + #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS // #define SPI_FREQUENCY 80000000 diff --git a/User_Setup_Select.h b/User_Setup_Select.h index de5c189..851d114 100644 --- a/User_Setup_Select.h +++ b/User_Setup_Select.h @@ -24,6 +24,7 @@ //#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 template for copying/editting @@ -32,7 +33,7 @@ ///////////////////////////////////////////////////////////////////////////////////// // // // DON'T TINKER WITH ANY OF THE FOLLOWING LINES, THESE ADD THE TFT DRIVERS // -// THEY ARE HERE FOR BODMER'S CONVENIENCE! // +// AND ESP8266 PIN DEFINITONS THEY ARE HERE FOR BODMER'S CONVENIENCE! // // // ///////////////////////////////////////////////////////////////////////////////////// diff --git a/library.json b/library.json index 46f4ffd..b1f620e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "0.16.3", + "version": "0.16.4", "keywords": "TFT, ESP8266, NodeMCU, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486", "description": "A TFT SPI graphics library for ESP8266", "repository": diff --git a/library.properties b/library.properties index 39c40d4..9dc9c54 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=0.16.3 +version=0.16.4 author=Bodmer maintainer=Bodmer sentence=A fast TFT library for ESP8266 processors and the Arduino IDE