Commit 4e6736e5 authored by Bodmer's avatar Bodmer

Add backlight support

The backlight control pin and ON state can be defined in the setup.h
file. Addresses #229, #226, #221

Comments updated and ILI9488 warning added.
parent 05359a4d
...@@ -121,10 +121,4 @@ ...@@ -121,10 +121,4 @@
writecommand(ILI9341_DISPON); //Display on writecommand(ILI9341_DISPON); //Display on
#ifdef M5STACK
// Turn on the back-light LED
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_BL, OUTPUT);
#endif
} }
\ No newline at end of file
...@@ -327,6 +327,17 @@ void TFT_eSPI::init(uint8_t tc) ...@@ -327,6 +327,17 @@ void TFT_eSPI::init(uint8_t tc)
writecommand(TFT_SWRST); // Software reset writecommand(TFT_SWRST); // Software reset
#endif #endif
#if defined (TFT_BL) && defined (TFT_BACKLIGHT_ON)
digitalWrite(TFT_BL, TFT_BACKLIGHT_ON);
pinMode(TFT_BL, OUTPUT);
#else
#if defined (TFT_BL) && defined (M5STACK)
// Turn on the back-light LED
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_BL, OUTPUT);
#endif
#endif
spi_end(); spi_end();
delay(150); // Wait for reset to complete delay(150); // Wait for reset to complete
......
...@@ -17,29 +17,32 @@ ...@@ -17,29 +17,32 @@
// 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 ST7735_DRIVER // Define additional parameters below for this display
//#define ILI9163_DRIVER //#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
//#define HX8357D_DRIVER //#define HX8357D_DRIVER
//#define ILI9481_DRIVER //#define ILI9481_DRIVER
//#define ILI9486_DRIVER //#define ILI9486_DRIVER
//#define ILI9488_DRIVER //#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
//#define ST7789_DRIVER // Define the screen size below for this display //#define ST7789_DRIVER // Define additional parameters below for this display
//#define R61581_DRIVER //#define R61581_DRIVER
// Some displays support SPI reads via the MISO pin, if the display has a single // Some displays support SPI reads via the MISO pin, other displays have a single
// bi-directional SDA pin the library will try to use bit banging to read the line // bi-directional SDA pin and the library will try to read this via the MOSI line.
// To use the SDA line for reading data from the TFT uncomment the following line: // To use the SDA line for reading data from the TFT uncomment the following line:
// #define TFT_SDA_READ
// #define TFT_SDA_READ // This option if for ESP32 ONLY, tested with ST7789 display only
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display // For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display // Try ONE option at a time to find the correct colour order for your display
//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below // #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
//#define M5STACK // #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below
// #define M5STACK
// For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation // For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
// #define TFT_WIDTH 80 // #define TFT_WIDTH 80
...@@ -65,13 +68,21 @@ ...@@ -65,13 +68,21 @@
// #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 (24 offset) (https://www.aliexpress.com/item/ShengYang-1pcs-IPS-0-96-inch-7P-SPI-HD-65K-Full-Color-OLED-Module-ST7735-Drive/32918394604.html) // #define ST7735_REDTAB160x80 // For 160 x 80 display with 24 pixel offset
// If colours are inverted (white shows as black) then uncomment one of the next // If colours are inverted (white shows as black) then uncomment one of the next
// 2 lines try both options, one of the options should correct the inversion. // 2 lines try both options, one of the options should correct the inversion.
//#define TFT_INVERSION_ON
//#define TFT_INVERSION_OFF
// #define TFT_INVERSION_ON
// #define TFT_INVERSION_OFF
// If a backlight control signal is available then define the TFT_BL pin in Section 2
// below. The backlight will be turned ON when tft.begin() is called, but the library
// needs to know if the LEDs are ON with the pin HIGH or LOW. If the LEDs are to be
// driven with a PWM signal or turned OFF/ON then this must be handled by the user
// sketch. e.g. with digitalWrite(TFT_BL, LOW);
// #define TFT_BACKLIGHT_ON HIGH // HIGH or LOW are options
// ################################################################################## // ##################################################################################
// //
......
...@@ -17,29 +17,32 @@ ...@@ -17,29 +17,32 @@
// 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 ST7735_DRIVER // Define additional parameters below for this display
//#define ILI9163_DRIVER //#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
//#define HX8357D_DRIVER //#define HX8357D_DRIVER
//#define ILI9481_DRIVER //#define ILI9481_DRIVER
//#define ILI9486_DRIVER //#define ILI9486_DRIVER
//#define ILI9488_DRIVER //#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
//#define ST7789_DRIVER // Define the screen size below for this display //#define ST7789_DRIVER // Define additional parameters below for this display
//#define R61581_DRIVER //#define R61581_DRIVER
// Some displays support SPI reads via the MISO pin, if the display has a single // Some displays support SPI reads via the MISO pin, other displays have a single
// bi-directional SDA pin the library will try to use bit banging to read the line // bi-directional SDA pin and the library will try to read this via the MOSI line.
// To use the SDA line for reading data from the TFT uncomment the following line: // To use the SDA line for reading data from the TFT uncomment the following line:
// #define TFT_SDA_READ
// For ST7789 ONLY, define the colour order if the blue and red are swapped on your display // #define TFT_SDA_READ // This option if for ESP32 ONLY, tested with ST7789 display only
// For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display
// Try ONE option at a time to find the correct colour order for your display // Try ONE option at a time to find the correct colour order for your display
//#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
//#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// For M5Stack ESP32 module with integrated display ONLY, remove // in line below // #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue
//#define M5STACK // #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red
// For M5Stack ESP32 module with integrated ILI9341 display ONLY, remove // in line below
// #define M5STACK
// For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation // For ST7789, ST7735 and ILI9163 ONLY, define the pixel width and height in portrait orientation
// #define TFT_WIDTH 80 // #define TFT_WIDTH 80
...@@ -65,13 +68,21 @@ ...@@ -65,13 +68,21 @@
// #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 (24 offset) (https://www.aliexpress.com/item/ShengYang-1pcs-IPS-0-96-inch-7P-SPI-HD-65K-Full-Color-OLED-Module-ST7735-Drive/32918394604.html) // #define ST7735_REDTAB160x80 // For 160 x 80 display with 24 pixel offset
// If colours are inverted (white shows as black) then uncomment one of the next // If colours are inverted (white shows as black) then uncomment one of the next
// 2 lines try both options, one of the options should correct the inversion. // 2 lines try both options, one of the options should correct the inversion.
//#define TFT_INVERSION_ON
//#define TFT_INVERSION_OFF
// #define TFT_INVERSION_ON
// #define TFT_INVERSION_OFF
// If a backlight control signal is available then define the TFT_BL pin in Section 2
// below. The backlight will be turned ON when tft.begin() is called, but the library
// needs to know if the LEDs are ON with the pin HIGH or LOW. If the LEDs are to be
// driven with a PWM signal or turned OFF/ON then this must be handled by the user
// sketch. e.g. with digitalWrite(TFT_BL, LOW);
// #define TFT_BACKLIGHT_ON HIGH // HIGH or LOW are options
// ################################################################################## // ##################################################################################
// //
...@@ -120,7 +131,7 @@ ...@@ -120,7 +131,7 @@
//#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)
//#define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen //#define TOUCH_CS PIN_D2 // Chip select pin (T_CS) of touch screen
//#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only //#define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only
...@@ -182,7 +193,7 @@ ...@@ -182,7 +193,7 @@
//#define ESP32_PARALLEL //#define ESP32_PARALLEL
// The ESP32 and TFT the pins used for testing are: // The ESP32 and TFT the pins used for testing are:
//#define TFT_CS 33 // Chip select control pin (library pulls permanently low) //#define TFT_CS 33 // Chip select control pin (library pulls permanently low
//#define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31 //#define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31
//#define TFT_RST 32 // Reset pin, toggles on startup //#define TFT_RST 32 // Reset pin, toggles on startup
...@@ -214,7 +225,7 @@ ...@@ -214,7 +225,7 @@
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters #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_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_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_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_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_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 LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
...@@ -226,7 +237,7 @@ ...@@ -226,7 +237,7 @@
// ################################################################################## // ##################################################################################
// //
// Section 5. Other options // Section 4. Other options
// //
// ################################################################################## // ##################################################################################
......
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "1.3.12", "version": "1.3.13",
"keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789", "keywords": "tft, ePaper, display, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789",
"description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32", "description": "A TFT and ePaper SPI graphics library for ESP8266 and ESP32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=1.3.12 version=1.3.13
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE sentence=A fast TFT graphics library for ESP8266 and ESP32 processors for the Arduino IDE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment