From de688f5ae70bfc2c2c4f5bcef3174204741e0b16 Mon Sep 17 00:00:00 2001 From: Bodmer Date: Sun, 11 Sep 2022 13:51:11 +0100 Subject: [PATCH] Move sketch tft_setup.h checking code --- TFT_eSPI.h | 18 ++++++++++++++++++ User_Setup_Select.h | 24 ++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 3ff0d23..3ac40df 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -39,6 +39,24 @@ #ifdef CONFIG_TFT_eSPI_ESPIDF #include "TFT_config.h" #endif + +// The following lines allow the user setup to be included in the sketch folder, see +// "Sketch_with_tft_setup" generic example. +#if !defined __has_include + #if !defined(DISABLE_ALL_LIBRARY_WARNINGS) + #warning Compiler does not support __has_include, so sketches cannot define the setup + #endif +#else + #if __has_include() + // Include the sketch setup file + #include + #ifndef USER_SETUP_LOADED + // Prevent loading further setups + #define USER_SETUP_LOADED + #endif + #endif +#endif + #include // Handle FLASH based storage e.g. PROGMEM diff --git a/User_Setup_Select.h b/User_Setup_Select.h index 55ac62b..bc11f86 100644 --- a/User_Setup_Select.h +++ b/User_Setup_Select.h @@ -5,34 +5,22 @@ // This makes selecting between hardware setups easy by "uncommenting" one line. // The advantage of this hardware configuration method is that the examples provided -// with the library should work with different setups immediately without any other -// changes being needed. It also improves the portability of users sketches to other -// hardware configurations and compatible libraries. +// with the library should work with immediately without any other changes being +// needed. It also improves the portability of users sketches to other hardware +// configurations and compatible libraries. // // Create a shortcut to this file on your desktop to permit quick access for editing. // Re-compile and upload after making and saving any changes to this file. // Customised User_Setup files are stored in the "User_Setups" folder. -// The following lines allow the user setup to be included in the sketch, see -// "Sketch_with_tft_setup" generic example. Do not edit lines 19 to 32! -#if !defined __has_include - #if !defined(DISABLE_ALL_LIBRARY_WARNINGS) - #warning Compiler does not support __has_include, so sketches cannot define the setup - #endif -#endif - -#if __has_include() - #include - #ifndef USER_SETUP_LOADED - #define USER_SETUP_LOADED - #endif -#endif +// It is also possible for the user tft settings to be included with the sketch, see +// the "Sketch_with_tft_setup" generic example. This may be more convenient for +// multiple projects. #ifndef USER_SETUP_LOADED // Lets PlatformIO users define settings in // platformio.ini, see notes in "Tools" folder. - /////////////////////////////////////////////////////// // User configuration selection lines are below // ///////////////////////////////////////////////////////