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
This commit is contained in:
Bodmer
2018-05-25 22:48:15 +01:00
parent af5a193bad
commit 4a52f5e685
6 changed files with 18 additions and 9 deletions

View File

@@ -140,8 +140,6 @@
ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay
100 }; // 100 ms delay 100 }; // 100 ms delay
tabcolor = TAB_COLOUR;
if (tabcolor == INITB) if (tabcolor == INITB)
{ {
commandList(Bcmd); commandList(Bcmd);

View File

@@ -209,9 +209,9 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
** Function name: begin ** Function name: begin
** Description: Included for backwards compatibility ** 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 ** Function name: init
** Description: Reset, then initialise the TFT display registers ** Description: Reset, then initialise the TFT display registers
***************************************************************************************/ ***************************************************************************************/
void TFT_eSPI::init(void) void TFT_eSPI::init(uint8_t tc)
{ {
#if !defined (ESP32) #if !defined (ESP32)
#ifdef TFT_CS #ifdef TFT_CS
@@ -307,6 +307,7 @@ void TFT_eSPI::init(void)
#include "TFT_Drivers/ILI9341_Init.h" #include "TFT_Drivers/ILI9341_Init.h"
#elif defined (ST7735_DRIVER) #elif defined (ST7735_DRIVER)
tabcolor = tc;
#include "TFT_Drivers/ST7735_Init.h" #include "TFT_Drivers/ST7735_Init.h"
#elif defined (ILI9163_DRIVER) #elif defined (ILI9163_DRIVER)
@@ -318,6 +319,9 @@ void TFT_eSPI::init(void)
#elif defined (RPI_ILI9486_DRIVER) #elif defined (RPI_ILI9486_DRIVER)
#include "TFT_Drivers/RPI_ILI9486_Init.h" #include "TFT_Drivers/RPI_ILI9486_Init.h"
#elif defined (ILI9486_DRIVER)
#include "TFT_Drivers/ILI9486_Init.h"
#elif defined (ILI9481_DRIVER) #elif defined (ILI9481_DRIVER)
#include "TFT_Drivers/ILI9481_Init.h" #include "TFT_Drivers/ILI9481_Init.h"
@@ -359,6 +363,9 @@ void TFT_eSPI::setRotation(uint8_t m)
#elif defined (RPI_ILI9486_DRIVER) #elif defined (RPI_ILI9486_DRIVER)
#include "TFT_Drivers/RPI_ILI9486_Rotation.h" #include "TFT_Drivers/RPI_ILI9486_Rotation.h"
#elif defined (ILI9486_DRIVER)
#include "TFT_Drivers/ILI9486_Rotation.h"
#elif defined (ILI9481_DRIVER) #elif defined (ILI9481_DRIVER)
#include "TFT_Drivers/ILI9481_Rotation.h" #include "TFT_Drivers/ILI9481_Rotation.h"

View File

@@ -21,6 +21,10 @@
// available and the pins to be used // available and the pins to be used
#include <User_Setup_Select.h> #include <User_Setup_Select.h>
#ifndef TAB_COLOUR
TAB_COLOUR 0
#endif
// If the frequency is not defined, set a default // If the frequency is not defined, set a default
#ifndef SPI_FREQUENCY #ifndef SPI_FREQUENCY
#define SPI_FREQUENCY 20000000 #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); 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 // 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), virtual void drawPixel(uint32_t x, uint32_t y, uint32_t color),

View File

@@ -8,7 +8,7 @@
// Data folder, press Ctrl+K to see this folder. Use the IDE "Tools" menu // Data folder, press Ctrl+K to see this folder. Use the IDE "Tools" menu
// option to upload the sketches data folder to the SPIFFS // 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
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@@ -7,7 +7,7 @@
// This example is part of the TFT_eSPI library: // This example is part of the TFT_eSPI library:
// https://github.com/Bodmer/TFT_eSPI // 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 #include "xbm.h" // Sketch tab header for xbm images

View File

@@ -8,7 +8,7 @@
verify the correct settings are being picked up by the compiler. 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 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 Written by Bodmer 9/4/18
*/ */