diff --git a/TFT_Drivers/ST7735_Defines.h b/TFT_Drivers/ST7735_Defines.h index 5048746..07c7c3f 100644 --- a/TFT_Drivers/ST7735_Defines.h +++ b/TFT_Drivers/ST7735_Defines.h @@ -1,7 +1,11 @@ // Change the width and height if required (defined in portrait mode) // or use the constructor to over-ride defaults -#define TFT_WIDTH 128 -#define TFT_HEIGHT 160 +#ifndef TFT_WIDTH + #define TFT_WIDTH 128 +#endif +#ifndef TFT_HEIGHT + #define TFT_HEIGHT 160 +#endif // Enumerate the different configurations @@ -9,6 +13,7 @@ #define INITR_REDTAB 0x1 #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 INITB 0xB @@ -21,7 +26,10 @@ #elif defined (ST7735_GREENTAB2) #define TAB_COLOUR INITR_GREENTAB2 - + +#elif defined (ST7735_GREENTAB3) + #define TAB_COLOUR INITR_GREENTAB3 + #elif defined (ST6635_REDTAB) #define TAB_COLOUR INITR_REDTAB diff --git a/TFT_Drivers/ST7735_Init.h b/TFT_Drivers/ST7735_Init.h index ebb7a66..9cb5dd5 100644 --- a/TFT_Drivers/ST7735_Init.h +++ b/TFT_Drivers/ST7735_Init.h @@ -163,6 +163,12 @@ colstart = 2; rowstart = 1; } + else if (tabcolor == INITR_GREENTAB3) + { + commandList(Rcmd2green); + colstart = 2; + rowstart = 3; + } else if (tabcolor == INITR_REDTAB) { commandList(Rcmd2red); diff --git a/TFT_Drivers/ST7735_Rotation.h b/TFT_Drivers/ST7735_Rotation.h index 2d6a00f..dceea31 100644 --- a/TFT_Drivers/ST7735_Rotation.h +++ b/TFT_Drivers/ST7735_Rotation.h @@ -12,7 +12,11 @@ writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB); colstart = 2; rowstart = 1; - } else { + } else if(tabcolor == INITR_GREENTAB3) { + writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); + colstart = 2; + rowstart = 3; + } else { writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); } _width = TFT_WIDTH; @@ -25,7 +29,11 @@ writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_RGB); colstart = 1; rowstart = 2; - } else { + } else if(tabcolor == INITR_GREENTAB3) { + writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); + colstart = 3; + rowstart = 2; + } else { writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); } _width = TFT_HEIGHT; @@ -38,6 +46,10 @@ writedata(TFT_MAD_RGB); colstart = 2; rowstart = 1; + } else if(tabcolor == INITR_GREENTAB3) { + writedata(TFT_MAD_BGR); + colstart = 2; + rowstart = 1; } else { writedata(TFT_MAD_BGR); } @@ -51,7 +63,11 @@ writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB); colstart = 1; rowstart = 2; - } else { + } else if(tabcolor == INITR_GREENTAB3) { + writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); + colstart = 1; + rowstart = 2; + } else { writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); } _width = TFT_HEIGHT; diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index ae82def..108aeea 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -1438,7 +1438,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 (GREENTAB2)) +#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) xs+=colstart; xe+=colstart; ys+=rowstart; @@ -1520,7 +1520,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 (GREENTAB2)) +#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) x0+=colstart; x1+=colstart; y0+=rowstart; @@ -1576,7 +1576,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 (GREENTAB2)) +#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) xs+=colstart; xe+=colstart; ys+=rowstart; @@ -1641,7 +1641,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 (GREENTAB2)) +#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) x0+=colstart; x1+=colstart; y0+=rowstart; @@ -1690,7 +1690,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 (GREENTAB2)) +#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) x+=colstart; y+=rowstart; #endif @@ -1774,7 +1774,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 (GREENTAB2)) +#if defined (ST7735_DRIVER) && (defined (ST7735_GREENTAB) || defined (ST7735_GREENTAB2) || defined (ST7735_GREENTAB3)) x+=colstart; y+=rowstart; #endif diff --git a/User_Setup.h b/User_Setup.h index f7c08a1..716f981 100644 --- a/User_Setup.h +++ b/User_Setup.h @@ -14,11 +14,30 @@ // ################################################################################## // Only define one driver, the other ones must be commented out -//#define ILI9341_DRIVER -#define ST7735_DRIVER +#define ILI9341_DRIVER +//#define ST7735_DRIVER //#define ILI9163_DRIVER //#define S6D02A1_DRIVER +// For ST7735 ONLY, define the type of display, originally this was based on the +// colour of the tab on the screen protector film but this is not always true, so try +// out the different options below if the screen does not display graphics correctly, +// e.g. colours wrong, mirror images, or tray pixels at the edges. +// Comment out ALL BUT ONE of these options for a ST7735 display driver, save this +// this User_Setup file, then rebuild and upload the sketch to the board again: + +//#define ST7735_INITB +//#define ST7735_GREENTAB +//#define ST7735_GREENTAB2 +//#define ST7735_GREENTAB3 +//#define ST7735_REDTAB +//#define ST7735_BLACKTAB + +// For ST7735 ONLY, define the pixel width and height in portrait orientation +//#define TFT_WIDTH 128 +//#define TFT_HEIGHT 160 +//#define TFT_HEIGHT 128 + // ################################################################################## // // Section 1. Define the pins that are used to interface with the display here diff --git a/User_Setups/Setup2_ST7735.h b/User_Setups/Setup2_ST7735.h index 54da24f..a09ad12 100644 --- a/User_Setups/Setup2_ST7735.h +++ b/User_Setups/Setup2_ST7735.h @@ -27,9 +27,15 @@ //#define ST7735_INITB //#define ST7735_GREENTAB //#define ST7735_GREENTAB2 +//#define ST7735_GREENTAB3 #define ST7735_REDTAB //#define ST7735_BLACKTAB +// For ST7735 ONLY define the width and height in portrait orientation +#define TFT_WIDTH 128 +#define TFT_HEIGHT 160 +//#define TFT_HEIGHT 128 + // ################################################################################## // // Section 1. Define the pins that are used to interface with the display here diff --git a/User_Setups/SetupX_Template.h b/User_Setups/SetupX_Template.h index ff513ea..52040b4 100644 --- a/User_Setups/SetupX_Template.h +++ b/User_Setups/SetupX_Template.h @@ -32,6 +32,11 @@ //#define ST7735_REDTAB //#define ST7735_BLACKTAB +// For ST7735 ONLY define the width and height in portrait orientation +//#define TFT_WIDTH 128 +//#define TFT_HEIGHT 160 +//#define TFT_HEIGHT 128 + // ################################################################################## // // Section 1. Define the pins that are used to interface with the display here