diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 73ad4d130..d20733e90 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -21,10 +21,6 @@ extern SX1509 gpioExtender; #if defined(ST7735S) #include // Graphics and font library for ST7735 driver chip -#if defined(ST7735_BACKLIGHT_EN) && !defined(TFT_BL) -#define TFT_BL ST7735_BACKLIGHT_EN -#endif - #ifndef TFT_INVERT #define TFT_INVERT true #endif @@ -91,18 +87,20 @@ class LGFX : public lgfx::LGFX_Device _panel_instance.config(cfg); } +#ifdef TFT_BL // Set the backlight control { auto cfg = _light_instance.config(); // Gets a structure for backlight settings. - cfg.pin_bl = ST7735_BL; // Pin number to which the backlight is connected - cfg.invert = true; // true to invert the brightness of the backlight + cfg.pin_bl = TFT_BL; // Pin number to which the backlight is connected + cfg.invert = true; // true to invert the brightness of the backlight // cfg.freq = 44100; // PWM frequency of backlight // cfg.pwm_channel = 1; // PWM channel number to use _light_instance.config(cfg); _panel_instance.setLight(&_light_instance); // Set the backlight on the panel. } +#endif setPanel(&_panel_instance); } @@ -575,14 +573,12 @@ void TFTDisplay::sendCommand(uint8_t com) display(true); if (settingsMap[displayBacklight] > 0) digitalWrite(settingsMap[displayBacklight], TFT_BACKLIGHT_ON); -#elif defined(ST7735_BL) - pinMode(ST7735_BL, OUTPUT); - digitalWrite(ST7735_BL, TFT_BACKLIGHT_ON); +#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) + pinMode(TFT_BL, OUTPUT); + digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) tft->wakeup(); tft->powerSaveOff(); -#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) - digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); #endif #ifdef VTFT_CTRL_V03 @@ -606,14 +602,12 @@ void TFTDisplay::sendCommand(uint8_t com) tft->clear(); if (settingsMap[displayBacklight] > 0) digitalWrite(settingsMap[displayBacklight], !TFT_BACKLIGHT_ON); -#elif defined(ST7735_BL) - pinMode(ST7735_BL, OUTPUT); - digitalWrite(ST7735_BL, !TFT_BACKLIGHT_ON); +#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) + pinMode(TFT_BL, OUTPUT); + digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #elif !defined(RAK14014) && !defined(M5STACK) && !defined(UNPHONE) tft->sleep(); tft->powerSaveOn(); -#elif defined(TFT_BL) && defined(TFT_BACKLIGHT_ON) - digitalWrite(TFT_BL, !TFT_BACKLIGHT_ON); #endif #ifdef VTFT_CTRL_V03 @@ -710,10 +704,6 @@ bool TFTDisplay::connect() LOG_INFO("Power to TFT Backlight\n"); #endif -#ifdef ST7735_BL - pinMode(ST7735_BL, OUTPUT); - digitalWrite(ST7735_BL, TFT_BACKLIGHT_ON); -#endif #ifdef UNPHONE unphone.backlight(true); // using unPhone library LOG_INFO("Power to TFT Backlight\n"); diff --git a/variants/chatter2/variant.h b/variants/chatter2/variant.h index 70438e52a..b7f946970 100644 --- a/variants/chatter2/variant.h +++ b/variants/chatter2/variant.h @@ -54,7 +54,7 @@ #define ST7735_RESET 15 #define ST7735_MISO -1 #define ST7735_BUSY -1 -#define ST7735_BL 32 +#define TFT_BL 32 #define ST7735_SPI_HOST HSPI_HOST // SPI2_HOST for S3, auto may work too #define SPI_FREQUENCY 40000000 #define SPI_READ_FREQUENCY 16000000 diff --git a/variants/heltec_wireless_tracker/variant.h b/variants/heltec_wireless_tracker/variant.h index f10612601..519c76d8f 100644 --- a/variants/heltec_wireless_tracker/variant.h +++ b/variants/heltec_wireless_tracker/variant.h @@ -15,7 +15,7 @@ #define ST7735_RESET 39 #define ST7735_MISO -1 #define ST7735_BUSY -1 -#define ST7735_BL 21 /* V1.1 PCB marking */ +#define TFT_BL 21 /* V1.1 PCB marking */ #define ST7735_SPI_HOST SPI3_HOST #define SPI_FREQUENCY 40000000 #define SPI_READ_FREQUENCY 16000000 diff --git a/variants/heltec_wireless_tracker_V1_0/variant.h b/variants/heltec_wireless_tracker_V1_0/variant.h index e97219163..b638dec53 100644 --- a/variants/heltec_wireless_tracker_V1_0/variant.h +++ b/variants/heltec_wireless_tracker_V1_0/variant.h @@ -15,7 +15,7 @@ #define ST7735_RESET 39 #define ST7735_MISO -1 #define ST7735_BUSY -1 -#define ST7735_BL 45 +#define TFT_BL 45 #define ST7735_SPI_HOST SPI3_HOST #define SPI_FREQUENCY 40000000 #define SPI_READ_FREQUENCY 16000000 diff --git a/variants/lora_relay_v1/variant.h b/variants/lora_relay_v1/variant.h index 54bc87b68..6efd711c6 100644 --- a/variants/lora_relay_v1/variant.h +++ b/variants/lora_relay_v1/variant.h @@ -144,7 +144,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #define ST7735_RESET (11) // Output #define ST7735_CS (12) -#define ST7735_BACKLIGHT_EN (13) +#define TFT_BL (13) #define ST7735_RS (9) // #define LORA_DISABLE_SENDING // The board can brownout during lora TX if you don't have a battery connected. Disable sending @@ -158,4 +158,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file diff --git a/variants/lora_relay_v2/variant.h b/variants/lora_relay_v2/variant.h index 6ef7ad7d6..f18f81034 100644 --- a/variants/lora_relay_v2/variant.h +++ b/variants/lora_relay_v2/variant.h @@ -166,7 +166,7 @@ static const uint8_t SCK = PIN_SPI_SCK; // ST7565 SPI #define ST7735_RESET (11) // Output #define ST7735_CS (12) -#define ST7735_BACKLIGHT_EN (13) +#define TFT_BL (13) #define ST7735_RS (9) #define ST7735_SDA (39) // actually spi MOSI #define ST7735_SCK (37) // actually spi clk @@ -185,4 +185,4 @@ static const uint8_t SCK = PIN_SPI_SCK; * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file diff --git a/variants/tracksenger/internal/variant.h b/variants/tracksenger/internal/variant.h index 75d81752b..bd4a51a2d 100644 --- a/variants/tracksenger/internal/variant.h +++ b/variants/tracksenger/internal/variant.h @@ -17,7 +17,7 @@ #define ST7735_RESET 39 #define ST7735_MISO -1 #define ST7735_BUSY -1 -#define ST7735_BL 21 /* V1.1 PCB marking */ +#define TFT_BL 21 /* V1.1 PCB marking */ #define ST7735_SPI_HOST SPI3_HOST #define SPI_FREQUENCY 40000000 #define SPI_READ_FREQUENCY 16000000 @@ -88,4 +88,4 @@ { \ 26, 37, 17, 16, 15, 7 \ } -// #end keyboard +// #end keyboard \ No newline at end of file diff --git a/variants/tracksenger/lcd/variant.h b/variants/tracksenger/lcd/variant.h index 7e814de68..17b012ae7 100644 --- a/variants/tracksenger/lcd/variant.h +++ b/variants/tracksenger/lcd/variant.h @@ -16,7 +16,7 @@ #define ST7789_CS 38 #define ST7789_RS 40 #define ST7789_BL 21 -// P#define ST7735_BL 21 /* V1.1 PCB marking */ +// P#define TFT_BL 21 /* V1.1 PCB marking */ #define ST7789_RESET -1 #define ST7789_MISO -1 @@ -41,7 +41,7 @@ // #define ST7735_RESET 39 // #define ST7735_MISO -1 // #define ST7735_BUSY -1 -#define ST7735_BL 21 /* V1.1 PCB marking */ +#define TFT_BL 21 /* V1.1 PCB marking */ // #define ST7735_SPI_HOST SPI3_HOST // #define SPI_FREQUENCY 40000000 // #define SPI_READ_FREQUENCY 16000000 @@ -112,4 +112,4 @@ { \ 26, 37, 17, 16, 15, 7 \ } -// #end keyboard +// #end keyboard \ No newline at end of file diff --git a/variants/tracksenger/oled/variant.h b/variants/tracksenger/oled/variant.h index 10bd7358b..e6e28e459 100644 --- a/variants/tracksenger/oled/variant.h +++ b/variants/tracksenger/oled/variant.h @@ -19,7 +19,7 @@ // #define ST7735_RESET 39 // #define ST7735_MISO -1 // #define ST7735_BUSY -1 -#define ST7735_BL 21 /* V1.1 PCB marking */ +#define TFT_BL 21 /* V1.1 PCB marking */ // #define ST7735_SPI_HOST SPI3_HOST // #define SPI_FREQUENCY 40000000 // #define SPI_READ_FREQUENCY 16000000