Add USER_SETUP_LOADED check to ESP-IDF config path #3709
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, if CONFIG_TFT_eSPI_ESPIDF was set, TFT_eSPI.h would unconditionally include TFT_config.h — even if USER_SETUP_LOADED was already defined (e.g., from User_Setup.h). This caused build errors due to missing or conflicting macros.
TFT_config.h is intended for ESP-IDF environments, while User_Setup.h is typically used in Arduino environments. However, this distinction breaks down when using PlatformIO with ESP-IDF as the base framework and Arduino as a component.
This change adds a check for USER_SETUP_LOADED even in the ESP-IDF codepath, giving users the flexibility to load their preferred configuration file. It avoids including TFT_config.h if a valid setup has already been provided.
This is especially useful in hybrid environments where ESP-IDF is used for system-level access (e.g., Bluetooth, low-level power control), but Arduino is used for everything else. In these cases, using User_Setup.h with PlatformIO may be preferred rather than relying on menuconfig.
This change maintains full compatibility with pure ESP-IDF setups that rely on TFT_config.h and idf.py menuconfig, while making the library more flexible in real-world mixed-mode builds.