From c016ea65f06defbe20a25049251a2815fcbbb0ec Mon Sep 17 00:00:00 2001 From: dracir Date: Thu, 14 Apr 2022 12:51:11 +0200 Subject: [PATCH] Fix TFT_eSprite crash and improve menu --- CMakeLists.txt | 4 +--- Kconfig | 55 +++++++++++++++++++++++++++++++++----------------- TFT_config.h | 24 +++++++++++++++------- TFT_eSPI.h | 7 +++---- 4 files changed, 57 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bc9e0f..b849c3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,4 @@ idf_component_register(SRCS "TFT_eSPI.cpp" INCLUDE_DIRS "." - PRIV_REQUIRES arduino) - -add_definitions(-DTFT_eSPI_COMPONENT) \ No newline at end of file + PRIV_REQUIRES arduino) \ No newline at end of file diff --git a/Kconfig b/Kconfig index 5c86f8a..5047d96 100644 --- a/Kconfig +++ b/Kconfig @@ -1,4 +1,12 @@ menu "TFT_eSPI" + + menu "Hidden menu" + visible if false + + config TFT_eSPI_ESPIDF + bool "Enable Configuration" + default y + endmenu choice TFT_DRIVER prompt "Select TFT driver" @@ -149,7 +157,7 @@ menu "TFT_eSPI" Use 8-bit parallel bus to send data to the LCD. If not set SPI will be used. menu "Display Data pins" - visible if TFT_PARALLEL_8_BIT + depends on TFT_PARALLEL_8_BIT config TFT_D0 int "Data 0 pin" default -1 @@ -202,7 +210,7 @@ menu "TFT_eSPI" endmenu menu "Display SPI config" - visible if !TFT_PARALLEL_8_BIT + depends on !TFT_PARALLEL_8_BIT config TFT_MISO int "TFT MISO pin" default -1 @@ -271,16 +279,19 @@ menu "TFT_eSPI" int "TFT Reset pin" default -1 range -1 33 + + config ENABLE_BL + bool "Enable backlight control" + default y + + if ENABLE_BL + config TFT_BL + int "TFT Backlight pin" + default -1 + range -1 33 + help + Pin for the backlight control signal - config TFT_BL - int "TFT Backlight pin" - default -1 - range -1 33 - help - Pin for the backlight control signal - Set to -1 to disable - - if TFT_BL >= 0 choice TFT_BACKLIGHT_ON bool "Pin state to activate backlight" default TFT_BACKLIGHT_ON_HIGH @@ -336,15 +347,21 @@ menu "TFT_eSPI" endmenu menu "Touch screen configuration" - config TOUCH_CS - int "Touch chip select pin" - default -1 - range -1 33 + config ENABLE_TOUCH + bool "Enable Touch" + default n - config SPI_TOUCH_FREQUENCY - int "SPI frequency for XPT2046 chip (Hz)" - default 2500000 - range 1 80000000 + if ENABLE_TOUCH + config TOUCH_CS + int "Touch chip select pin" + default -1 + range -1 33 + + config SPI_TOUCH_FREQUENCY + int "SPI frequency for XPT2046 chip (Hz)" + default 2500000 + range 1 80000000 + endif endmenu endmenu diff --git a/TFT_config.h b/TFT_config.h index d77a3eb..1ad5a2f 100644 --- a/TFT_config.h +++ b/TFT_config.h @@ -1,9 +1,9 @@ /** - * @file utility.h + * @file TFT_config.h * @author Ricard Bitriá Ribes (https://github.com/dracir9) * Created Date: 22-01-2022 * ----- - * Last Modified: 11-04-2022 + * Last Modified: 14-04-2022 * Modified By: Ricard Bitriá Ribes * ----- * @copyright (c) 2022 Ricard Bitriá Ribes @@ -134,8 +134,13 @@ #endif // Backlight config -#if CONFIG_TFT_BL != -1 - #define TFT_BL CONFIG_TFT_BL +#ifdef CONFIG_ENABLE_BL + #if CONFIG_TFT_BL == -1 + #error "Invalid backlight control pin. Check TFT_eSPI configuration" + #else + #define TFT_BL CONFIG_TFT_BL + #endif + #define TFT_BACKLIGHT_ON CONFIG_TFT_BACKLIGHT_ON #endif @@ -209,7 +214,6 @@ // SPI BUS #else - #if CONFIG_TFT_MISO == -1 #error "Invalid MISO pin. Check TFT_eSPI configuration" #else @@ -280,8 +284,14 @@ ** Section 5: Touchscreen configuration ***************************************************************************************/ -#define TOUCH_CS CONFIG_TOUCH_CS +#ifdef CONFIG_ENABLE_TOUCH + #if CONFIG_TOUCH_CS == -1 + #error "Invalid Touch Chip Select pin. Check TFT_eSPI configuration" + #else + #define TOUCH_CS CONFIG_TOUCH_CS + #endif -#define SPI_TOUCH_FREQUENCY CONFIG_SPI_TOUCH_FREQUENCY + #define SPI_TOUCH_FREQUENCY CONFIG_SPI_TOUCH_FREQUENCY +#endif #endif // TFT_CONFIG_H diff --git a/TFT_eSPI.h b/TFT_eSPI.h index a4762c4..6fc925d 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -27,10 +27,6 @@ ***************************************************************************************/ //Standard support -#ifdef TFT_eSPI_COMPONENT -#include "TFT_config.h" -#endif - #include #include #include @@ -40,6 +36,9 @@ ***************************************************************************************/ // Include header file that defines the fonts loaded, the TFT drivers // available and the pins to be used, etc, etc +#ifdef CONFIG_TFT_eSPI_ESPIDF +#include "TFT_config.h" +#endif #include // Handle FLASH based storage e.g. PROGMEM