[Deprecated due to a number of issues with this approach] User setup in the sketch #2007
Replies: 11 comments 6 replies
This comment has been hidden.
This comment has been hidden.
-
Edit: This approach is now deprecated as it is causing a number of issues. I have done some research on the basis that it must be possible to bypass the blockage put in place by the Arduino IDE. I found a work-around that allows a setup file inside the sketch. The procedure is as follows:
Let me know if you get this working, then I will include these instructions in a future library update. |
Beta Was this translation helpful? Give feedback.
-
Caveat: The approach works by including the sketch folder in the compile path for all libraries and the board package. The proposed approach works with the examples in this library however it can result in the sketch failing to compile when some additional libraries are used. So, a known working test sketch should be used to verify the apporach is compatible with the board packages, libraries and code included in your sketch. |
Beta Was this translation helpful? Give feedback.
-
exactly, I have a somewhat complex application and I have errors with WiFiManager, too bad! |
Beta Was this translation helpful? Give feedback.
-
I have just downloaded IDE version 2.0 to try. It does seem to cause problems as you say with the proposed approach. I had another go at using the build_opt.h approach and it worked. You need to include a file with the name build_opt.h in the sketch. I thought this did not work until I realised that edits to this file can be ignored by the IDE becuase it uses a cached copy of the library from a previous compilation. To get around this you must clear the cache, the only way I found to do this with Arduino IDE 2.0.0 is to select a different processor, compile the sketch (even though this might generate errors) then swap back to the desired processor and compile/upload again. This clumsy cache clear process process MUST be repeated if another sketch is loaded with different content in the build_opt.h file. See here for example and caveats: Here is an example content of the required format for the build_opt.h header file, this is for an 8 bit parallel display with an ESP32 but the same approach should work with SPI or other setups.
Essentially a setup #define is replaced by -D, no spaces are used and the =xx must be included. Comment out all setup file path lines in the User_Setup_Select.h file to avoid conflicts. |
Beta Was this translation helpful? Give feedback.
-
I've raised this cache issue with the Arduino team on the forum here: https://forum.arduino.cc/t/cache-clear-option/1040106 Please login and express a desire for this feature in the forum topic. Hopefully this will then encourage the Arduino team to implement such a simple and useful feature. |
Beta Was this translation helpful? Give feedback.
-
Note that not all board packages implement support for using build_opt.h in the sketch. The ESP32 board package does support it but sadly the RP2040 board package does not. |
Beta Was this translation helpful? Give feedback.
-
i've tried a user setup in the sketch, putting the file in the directory of esp8266 where the board.txt is,but had an error,so i |
Beta Was this translation helpful? Give feedback.
-
I created a 'build_opt.h' file in the project directory and without any configure screen in 'User_Setup_Select.h' , and it works
|
Beta Was this translation helpful? Give feedback.
-
hi @Bodmer #if __has_include(<build_opt.h>)
#include <build_opt.h>
... then we would have a somewhat portable means to set library options without changing the library code? |
Beta Was this translation helpful? Give feedback.
-
Hello to everyone! First of all I would like to thank Bodmer for good library. |
Beta Was this translation helpful? Give feedback.
-
Hello! I am using the Arduino IDE and am not sure how best to store a different hardware setup within each sketch.
I have a number of different projects which have different hardware setups, and editing the library's
User_Setup_Select.h
file for each sketch doesn't seem like a great way to store the right settings for each project.I have tried copying one of the
User_Setups/*.h
files into my sketch and including it beforeTFT_eSPI.h
, but it doesn't seem to honor the pin selections. I also tried definingUSER_SETUP_LOADED
with no apparent change.What's the best way to store TFT_eSPI hardware settings along with the sketch?
Thanks so much! I appreciate any guidance you can offer.
Beta Was this translation helpful? Give feedback.
All reactions