From 4a52f5e6851875ddf64a4378e3404a058330e907 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Fri, 25 May 2018 22:48:15 +0100 Subject: [PATCH] Add ability to set ST7735 tab color from sketch Use line is form: tft.init(1); or: tft.init(INITR_REDTAB); // Enumerated the configurations in library are: #define INITR_GREENTAB 0x0 #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 INITR_GREENTAB128 0x5 // Use if you only get part of 128x128 screen in rotation 0 & 1 #define INITB 0xB --- TFT_Drivers/ST7735_Init.h | 2 -- TFT_eSPI.cpp | 13 ++++++++++--- TFT_eSPI.h | 6 +++++- examples/Generic/TFT_SPIFFS_BMP/TFT_SPIFFS_BMP.ino | 2 +- examples/Generic/drawXBitmap/drawXBitmap.ino | 2 +- .../Read_User_Setup/Read_User_Setup.ino | 2 +- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/TFT_Drivers/ST7735_Init.h b/TFT_Drivers/ST7735_Init.h index 41a9c9d..0df152c 100644 --- a/TFT_Drivers/ST7735_Init.h +++ b/TFT_Drivers/ST7735_Init.h @@ -140,8 +140,6 @@ ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay 100 }; // 100 ms delay - tabcolor = TAB_COLOUR; - if (tabcolor == INITB) { commandList(Bcmd); diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index b5e2164..c13b596 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -209,9 +209,9 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h) ** Function name: begin ** Description: Included for backwards compatibility ***************************************************************************************/ -void TFT_eSPI::begin(void) +void TFT_eSPI::begin(uint8_t tc) { - init(); + init(tc); } @@ -219,7 +219,7 @@ void TFT_eSPI::begin(void) ** Function name: init ** Description: Reset, then initialise the TFT display registers ***************************************************************************************/ -void TFT_eSPI::init(void) +void TFT_eSPI::init(uint8_t tc) { #if !defined (ESP32) #ifdef TFT_CS @@ -307,6 +307,7 @@ void TFT_eSPI::init(void) #include "TFT_Drivers/ILI9341_Init.h" #elif defined (ST7735_DRIVER) + tabcolor = tc; #include "TFT_Drivers/ST7735_Init.h" #elif defined (ILI9163_DRIVER) @@ -318,6 +319,9 @@ void TFT_eSPI::init(void) #elif defined (RPI_ILI9486_DRIVER) #include "TFT_Drivers/RPI_ILI9486_Init.h" +#elif defined (ILI9486_DRIVER) + #include "TFT_Drivers/ILI9486_Init.h" + #elif defined (ILI9481_DRIVER) #include "TFT_Drivers/ILI9481_Init.h" @@ -359,6 +363,9 @@ void TFT_eSPI::setRotation(uint8_t m) #elif defined (RPI_ILI9486_DRIVER) #include "TFT_Drivers/RPI_ILI9486_Rotation.h" +#elif defined (ILI9486_DRIVER) + #include "TFT_Drivers/ILI9486_Rotation.h" + #elif defined (ILI9481_DRIVER) #include "TFT_Drivers/ILI9481_Rotation.h" diff --git a/TFT_eSPI.h b/TFT_eSPI.h index e17774f..86e7cf8 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -21,6 +21,10 @@ // available and the pins to be used #include +#ifndef TAB_COLOUR + TAB_COLOUR 0 +#endif + // If the frequency is not defined, set a default #ifndef SPI_FREQUENCY #define SPI_FREQUENCY 20000000 @@ -491,7 +495,7 @@ class TFT_eSPI : public Print { TFT_eSPI(int16_t _W = TFT_WIDTH, int16_t _H = TFT_HEIGHT); - void init(void), begin(void); // Same - begin included for backwards compatibility + void init(uint8_t tc = TAB_COLOUR), begin(uint8_t tc = TAB_COLOUR); // Same - begin included for backwards compatibility // These are virtual so the TFT_eSprite class can override them with sprite specific functions virtual void drawPixel(uint32_t x, uint32_t y, uint32_t color), diff --git a/examples/Generic/TFT_SPIFFS_BMP/TFT_SPIFFS_BMP.ino b/examples/Generic/TFT_SPIFFS_BMP/TFT_SPIFFS_BMP.ino index a40ce4c..df43a4d 100644 --- a/examples/Generic/TFT_SPIFFS_BMP/TFT_SPIFFS_BMP.ino +++ b/examples/Generic/TFT_SPIFFS_BMP/TFT_SPIFFS_BMP.ino @@ -8,7 +8,7 @@ // Data folder, press Ctrl+K to see this folder. Use the IDE "Tools" menu // option to upload the sketches data folder to the SPIFFS -// This sketch ahs been tested on the ESP32 and ESP8266 +// This sketch has been tested on the ESP32 and ESP8266 //---------------------------------------------------------------------------------------------------- diff --git a/examples/Generic/drawXBitmap/drawXBitmap.ino b/examples/Generic/drawXBitmap/drawXBitmap.ino index 8678c31..d43138e 100644 --- a/examples/Generic/drawXBitmap/drawXBitmap.ino +++ b/examples/Generic/drawXBitmap/drawXBitmap.ino @@ -7,7 +7,7 @@ // This example is part of the TFT_eSPI library: // https://github.com/Bodmer/TFT_eSPI -// Created by Bodmer 23/14/18 +// Created by Bodmer 23/04/18 #include "xbm.h" // Sketch tab header for xbm images diff --git a/examples/Test and diagnostics/Read_User_Setup/Read_User_Setup.ino b/examples/Test and diagnostics/Read_User_Setup/Read_User_Setup.ino index f326cad..45d48bf 100644 --- a/examples/Test and diagnostics/Read_User_Setup/Read_User_Setup.ino +++ b/examples/Test and diagnostics/Read_User_Setup/Read_User_Setup.ino @@ -8,7 +8,7 @@ verify the correct settings are being picked up by the compiler. If support is needed the output can be cut and pasted into an Arduino Forum post and - already inlcudes the formatting [code]...[/code] markups. + already includes the formatting [code]...[/code] markups. Written by Bodmer 9/4/18 */