External function to manipulate pins
This commit is contained in:
parent
c5972a52a1
commit
74b8024dc9
11
TFT_eSPI.cpp
11
TFT_eSPI.cpp
|
|
@ -266,7 +266,6 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Function name: begin
|
** Function name: begin
|
||||||
** Description: Included for backwards compatibility
|
** Description: Included for backwards compatibility
|
||||||
|
|
@ -276,15 +275,18 @@ void TFT_eSPI::begin(uint8_t tc)
|
||||||
init(tc);
|
init(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
** Function name: init (tc is tab colour for ST7735 displays only)
|
** Function name: init (tc is tab colour for ST7735 displays only)
|
||||||
** Description: Reset, then initialise the TFT display registers
|
** Description: Reset, then initialise the TFT display registers
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
void TFT_eSPI::init(uint8_t tc)
|
void TFT_eSPI::init(uint8_t tc, void (*ext_dc_func)(bool state), void (*ext_cs_func)(bool state), void (*ext_rst_func)(void))
|
||||||
{
|
{
|
||||||
if (_booted)
|
if (_booted)
|
||||||
{
|
{
|
||||||
|
ext_cs = ext_cs_func;
|
||||||
|
ext_dc = ext_dc_func;
|
||||||
|
ext_rst = ext_rst_func;
|
||||||
|
|
||||||
#if !defined (ESP32)
|
#if !defined (ESP32)
|
||||||
#if defined (TFT_CS) && (TFT_CS >= 0)
|
#if defined (TFT_CS) && (TFT_CS >= 0)
|
||||||
cspinmask = (uint32_t) digitalPinToBitMask(TFT_CS);
|
cspinmask = (uint32_t) digitalPinToBitMask(TFT_CS);
|
||||||
|
|
@ -368,7 +370,8 @@ void TFT_eSPI::init(uint8_t tc)
|
||||||
}
|
}
|
||||||
else writecommand(TFT_SWRST); // Software reset
|
else writecommand(TFT_SWRST); // Software reset
|
||||||
#else
|
#else
|
||||||
writecommand(TFT_SWRST); // Software reset
|
if (ext_rst) ext_rst(); // External function for reset
|
||||||
|
else writecommand(TFT_SWRST); // Software reset
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
spi_end();
|
spi_end();
|
||||||
|
|
|
||||||
15
TFT_eSPI.h
15
TFT_eSPI.h
|
|
@ -125,8 +125,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TFT_DC
|
#ifndef TFT_DC
|
||||||
#define DC_C // No macro allocated so it generates no code
|
#define DC_C if(ext_dc) ext_dc(false) // If callback set, call function
|
||||||
#define DC_D // No macro allocated so it generates no code
|
#define DC_D if(ext_dc) ext_dc(true) // If callback set, call function
|
||||||
#else
|
#else
|
||||||
#if defined (ESP8266) && (TFT_DC == 16)
|
#if defined (ESP8266) && (TFT_DC == 16)
|
||||||
#define DC_C digitalWrite(TFT_DC, LOW)
|
#define DC_C digitalWrite(TFT_DC, LOW)
|
||||||
|
|
@ -182,8 +182,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TFT_CS
|
#ifndef TFT_CS
|
||||||
#define CS_L // No macro allocated so it generates no code
|
#define CS_L if(ext_cs) ext_cs(false) // If callback set, call function
|
||||||
#define CS_H // No macro allocated so it generates no code
|
#define CS_H if(ext_cs) ext_cs(true) // If callback set, call function
|
||||||
#else
|
#else
|
||||||
#if defined (ESP8266) && (TFT_CS == 16)
|
#if defined (ESP8266) && (TFT_CS == 16)
|
||||||
#define CS_L digitalWrite(TFT_CS, LOW)
|
#define CS_L digitalWrite(TFT_CS, LOW)
|
||||||
|
|
@ -664,8 +664,8 @@ 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(uint8_t tc = TAB_COLOUR), begin(uint8_t tc = TAB_COLOUR); // Same - begin included for backwards compatibility
|
void init(uint8_t tc = TAB_COLOUR, void (*ext_dc_func)(bool state) = NULL, void (*ext_cs_func)(bool state) = NULL, void (*ext_rst_func)(void) = NULL), 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(int32_t x, int32_t y, uint32_t color),
|
virtual void drawPixel(int32_t x, int32_t y, uint32_t color),
|
||||||
drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t size),
|
drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t size),
|
||||||
|
|
@ -850,6 +850,9 @@ class TFT_eSPI : public Print {
|
||||||
uint16_t decoderBuffer; // Unicode code-point buffer
|
uint16_t decoderBuffer; // Unicode code-point buffer
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void (*ext_dc)(bool state);
|
||||||
|
void (*ext_cs)(bool state);
|
||||||
|
void (*ext_rst)(void);
|
||||||
|
|
||||||
inline void spi_begin() __attribute__((always_inline));
|
inline void spi_begin() __attribute__((always_inline));
|
||||||
inline void spi_end() __attribute__((always_inline));
|
inline void spi_end() __attribute__((always_inline));
|
||||||
|
|
|
||||||
12
User_Setup.h
12
User_Setup.h
|
|
@ -16,8 +16,8 @@
|
||||||
// ##################################################################################
|
// ##################################################################################
|
||||||
|
|
||||||
// Only define one driver, the other ones must be commented out
|
// Only define one driver, the other ones must be commented out
|
||||||
#define ILI9341_DRIVER
|
//#define ILI9341_DRIVER
|
||||||
//#define ST7735_DRIVER // Define additional parameters below for this display
|
#define ST7735_DRIVER // Define additional parameters below for this display
|
||||||
//#define ILI9163_DRIVER // Define additional parameters below for this display
|
//#define ILI9163_DRIVER // Define additional parameters below for this display
|
||||||
//#define S6D02A1_DRIVER
|
//#define S6D02A1_DRIVER
|
||||||
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
// #define ST7735_GREENTAB3
|
// #define ST7735_GREENTAB3
|
||||||
// #define ST7735_GREENTAB128 // For 128 x 128 display
|
// #define ST7735_GREENTAB128 // For 128 x 128 display
|
||||||
// #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
|
// #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset)
|
||||||
// #define ST7735_REDTAB
|
#define ST7735_REDTAB
|
||||||
// #define ST7735_BLACKTAB
|
// #define ST7735_BLACKTAB
|
||||||
// #define ST7735_REDTAB160x80 // For 160 x 80 display with 24 pixel offset
|
// #define ST7735_REDTAB160x80 // For 160 x 80 display with 24 pixel offset
|
||||||
|
|
||||||
|
|
@ -125,9 +125,9 @@
|
||||||
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP8266 SETUP ######
|
// ###### EDIT THE PIN NUMBERS IN THE LINES FOLLOWING TO SUIT YOUR ESP8266 SETUP ######
|
||||||
|
|
||||||
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
|
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
|
||||||
#define TFT_CS PIN_D8 // Chip select control pin D8
|
//#define TFT_CS PIN_D8 // Chip select control pin D8
|
||||||
#define TFT_DC PIN_D3 // Data Command control pin
|
//#define TFT_DC PIN_D0 // Data Command control pin
|
||||||
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
|
//#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
|
||||||
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||||
|
|
||||||
//#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)
|
//#define TFT_BL PIN_D1 // LED back-light (only for ST7789 with backlight control pin)
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
// Only ONE line below should be uncommented. Add extra lines and files as needed.
|
// Only ONE line below should be uncommented. Add extra lines and files as needed.
|
||||||
|
|
||||||
#include <User_Setup.h> // Default setup is root library folder
|
//#include <User_Setup.h> // Default setup is root library folder
|
||||||
|
#include <User_Setups/SDMoto18_ST7735.h> // Setup file configured for my ST7735
|
||||||
//#include <User_Setups/Setup1_ILI9341.h> // Setup file configured for my ILI9341
|
//#include <User_Setups/Setup1_ILI9341.h> // Setup file configured for my ILI9341
|
||||||
//#include <User_Setups/Setup2_ST7735.h> // Setup file configured for my ST7735
|
//#include <User_Setups/Setup2_ST7735.h> // Setup file configured for my ST7735
|
||||||
//#include <User_Setups/Setup3_ILI9163.h> // Setup file configured for my ILI9163
|
//#include <User_Setups/Setup3_ILI9163.h> // Setup file configured for my ILI9163
|
||||||
|
|
@ -125,7 +125,6 @@
|
||||||
#define TFT_DRIVER 0x0000
|
#define TFT_DRIVER 0x0000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// These are the pins for ESP8266 boards
|
// These are the pins for ESP8266 boards
|
||||||
// Name GPIO NodeMCU Function
|
// Name GPIO NodeMCU Function
|
||||||
#define PIN_D0 D0 // GPIO16 WAKE
|
#define PIN_D0 D0 // GPIO16 WAKE
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
// See SetupX_Template.h for all options available
|
||||||
|
|
||||||
|
#define ST7735_DRIVER
|
||||||
|
|
||||||
|
|
||||||
|
#define TFT_WIDTH 128
|
||||||
|
#define TFT_HEIGHT 160
|
||||||
|
|
||||||
|
|
||||||
|
#define ST7735_REDTAB
|
||||||
|
|
||||||
|
|
||||||
|
// For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation
|
||||||
|
//#define TFT_CS PIN_D8 // Chip select control pin D8
|
||||||
|
//#define TFT_DC PIN_D0 // Data Command control pin
|
||||||
|
#define TFT_DC 16 // Data Command control pin (no Arduino IDE)
|
||||||
|
//#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
|
||||||
|
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V
|
||||||
|
|
||||||
|
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
|
||||||
|
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
|
||||||
|
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
|
||||||
|
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
|
||||||
|
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
|
||||||
|
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
|
||||||
|
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
|
||||||
|
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
|
||||||
|
|
||||||
|
#define SMOOTH_FONT
|
||||||
|
|
||||||
|
|
||||||
|
// #define SPI_FREQUENCY 20000000
|
||||||
|
#define SPI_FREQUENCY 27000000
|
||||||
|
// #define SPI_FREQUENCY 40000000
|
||||||
|
|
||||||
|
#define SPI_TOUCH_FREQUENCY 2500000
|
||||||
|
|
||||||
|
|
||||||
|
// #define SUPPORT_TRANSACTIONS
|
||||||
Loading…
Reference in New Issue