From fb86ae4d1bf785e377fd11caec88db7bf614dddb Mon Sep 17 00:00:00 2001 From: Bodmer Date: Sat, 6 Jun 2020 14:55:02 +0100 Subject: [PATCH] Update Read_User_Setup add #648 Read_User_Setup now includes backlight settings --- TFT_eSPI.cpp | 38 ++++++++++++------- TFT_eSPI.h | 5 ++- .../Read_User_Setup/Read_User_Setup.ino | 14 +++++++ library.json | 2 +- library.properties | 2 +- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/TFT_eSPI.cpp b/TFT_eSPI.cpp index 5242b42..b2cb678 100644 --- a/TFT_eSPI.cpp +++ b/TFT_eSPI.cpp @@ -2614,9 +2614,6 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1) { //begin_tft_write(); // Must be called before setWindow - addr_col = 0xFFFF; - addr_row = 0xFFFF; - #ifdef CGRAM_OFFSET x0+=colstart; x1+=colstart; @@ -2624,16 +2621,21 @@ void TFT_eSPI::setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1) y1+=rowstart; #endif - // Column addr set - DC_C; tft_Write_8(TFT_CASET); - DC_D; tft_Write_32C(x0, x1); + // No need to send x if it has not changed (speeds things up) + if (addr_col != (x0<<16 | x1)) { + DC_C; tft_Write_8(TFT_CASET); + DC_D; tft_Write_32C(x0, x1); + addr_col = (x0<<16 | x1); + } - // Row addr set - DC_C; tft_Write_8(TFT_PASET); - DC_D; tft_Write_32C(y0, y1); + // No need to send y if it has not changed (speeds things up) + if (addr_row != (y0<<16 | y1)) { + DC_C; tft_Write_8(TFT_PASET); + DC_D; tft_Write_32C(y0, y1); + addr_row = (y0<<16 | y1); + } DC_C; tft_Write_8(TFT_RAMWR); - DC_D; //end_tft_write(); // Must be called after setWindow @@ -2695,17 +2697,17 @@ void TFT_eSPI::drawPixel(int32_t x, int32_t y, uint32_t color) begin_tft_write(); // No need to send x if it has not changed (speeds things up) - if (addr_col != x) { + if (addr_col != (x<<16 | x)) { DC_C; tft_Write_8(TFT_CASET); DC_D; tft_Write_32D(x); - addr_col = x; + addr_col = (x<<16 | x); } // No need to send y if it has not changed (speeds things up) - if (addr_row != y) { + if (addr_row != (y<<16 | y)) { DC_C; tft_Write_8(TFT_PASET); DC_D; tft_Write_32D(y); - addr_row = y; + addr_row = (y<<16 | y); } DC_C; tft_Write_8(TFT_RAMWR); @@ -4204,6 +4206,14 @@ void TFT_eSPI::getSetup(setup_t &tft_settings) tft_settings.pin_tft_d7 = -1; #endif +#if defined (TFT_BL) + tft_settings.pin_tft_led = TFT_BL; +#endif + +#if defined (TFT_BACKLIGHT_ON) + tft_settings.pin_tft_led_on = TFT_BACKLIGHT_ON; +#endif + #if defined (TOUCH_CS) tft_settings.pin_tch_cs = TOUCH_CS; tft_settings.tch_spi_freq = SPI_TOUCH_FREQUENCY/100000; diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 49b932d..8fc7c74 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.2.9" +#define TFT_ESPI_VERSION "2.2.10" /*************************************************************************************** ** Section 1: Load required header files @@ -335,6 +335,9 @@ int8_t pin_tft_d5; int8_t pin_tft_d6; int8_t pin_tft_d7; +int8_t pin_tft_led; +int8_t pin_tft_led_on; + int8_t pin_tch_cs; // Touch chip select pin int16_t tft_spi_freq;// TFT write SPI frequency 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 ab823ea..7530051 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 @@ -61,6 +61,7 @@ if (user.tft_driver != 0xE9D) // For ePaper displays the size is defined in the Serial.print("Display driver = "); Serial.println(user.tft_driver, HEX); // Hexadecimal code Serial.print("Display width = "); Serial.println(user.tft_width); // Rotation 0 width and height Serial.print("Display height = "); Serial.println(user.tft_height); + Serial.println(); } else if (user.tft_driver == 0xE9D) Serial.println("Display driver = ePaper\n"); @@ -97,6 +98,10 @@ if (user.overlap == true) } #endif String pinNameRef = "GPIO "; +#ifdef ESP8266 + pinNameRef = "PIN_D"; +#endif + if (user.esp == 0x32F) { Serial.println("\n>>>>> Note: STM32 pin references above D15 may not reflect board markings <<<<<"); pinNameRef = "D"; @@ -119,6 +124,15 @@ if (user.pin_tft_d5 != -1) { Serial.print("TFT_D5 = " + pinNameRef); Serial.pr if (user.pin_tft_d6 != -1) { Serial.print("TFT_D6 = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d6)); } if (user.pin_tft_d7 != -1) { Serial.print("TFT_D7 = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d7)); } +#if defined (TFT_BL) + Serial.print("\nTFT_BL = " + pinNameRef); Serial.println(getPinName(user.pin_tft_led)); + #if defined (TFT_BACKLIGHT_ON) + Serial.print("TFT_BACKLIGHT_ON = "); Serial.println(user.pin_tft_led_on == HIGH ? "HIGH" : "LOW"); + #endif +#endif + +Serial.println(); + uint16_t fonts = tft.fontsLoaded(); if (fonts & (1 << 1)) Serial.print("Font GLCD loaded\n"); if (fonts & (1 << 2)) Serial.print("Font 2 loaded\n"); diff --git a/library.json b/library.json index a17e9ee..67b178d 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.2.9", + "version": "2.2.10", "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", "repository": diff --git a/library.properties b/library.properties index 8dd4766..33c9b5a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.2.9 +version=2.2.10 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32