Replies: 9 comments 5 replies
-
The Arduino IDE does not allow sketch #defines to be visible to a library hence the use of setup files. If you use PlatformIO as the IDE then you can have project based setups in the platformio.ini files see tools folder. One possibility with the Arduino IDE is to generate a board type specific to a project but there are no tools to do this, and it would still be necessary to select the right board in the IDE when a different setup is wanted. It might be possible to write an add in for the IDE that behaves as as project manager but I have not tried that. Another option is to allow a sketch to detect the setup in use and generate a compile time error if it is wrong. That would be an easy to add feature. |
Beta Was this translation helpful? Give feedback.
-
thank you Bodmer - it seems Arduino is for lamers so I am one of them and I need to stay there as Platformio has other things that are not working i.e. S2 is still not there |
Beta Was this translation helpful? Give feedback.
-
btw I made it working by using some macros - in case someone is interested in how (maybe dirty code but... working). for ILI I use: I actually at this moment of time use only these two. Then in void setup():
this way the compilation stops when wrong file is selected in User_Setup_Select.h |
Beta Was this translation helpful? Give feedback.
-
I will be adding the capability to read info defined in the user_setup file at the next release. Although the Arduino IDE prevents a #define in the sketch from being recognised by the library, the reverse is possible a library #define is visible to the sketch. So if you add things to the setup file like:
The sketch has access to these, so you can generate an error message is the wrong setup is being used. Add lines like this to the sketch:
Note that the #define is not available to the sketch until after the #include <TFT_eSPI.h> |
Beta Was this translation helpful? Give feedback.
-
I see you have already adopted the above approach. I am also adding an ID check function although that is strictly not necessary.
|
Beta Was this translation helpful? Give feedback.
-
I am not sure if this is me only but whenever you update your library ALL FILES are overwritten with the new ones, right?
and then I only uncomment 1st and comment 2nd |
Beta Was this translation helpful? Give feedback.
-
I am sure I took it from there wouldn't that work? Proposal 2: I see i.e. that it can be either: I am thinking logically even? I am not a professional programmer ;-) |
Beta Was this translation helpful? Give feedback.
-
Could it bé possible to define insta thé sketch thé pin (formation example (#DEFINE TFT_MOSI 15) instead offre into thé setup filé ? |
Beta Was this translation helpful? Give feedback.
-
See here for a work-around that allows the setup file to be included in the sketch: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I know I can uncomment 1 line and comment the other one in the "User_Setup_Select.h" file, to have my setup included (per display).
But, I am thinking about more robust way.
Why?
Since I have few displays and projects, it happened to me already few times to compile the project with "wrong" display.
Outcome? Nothing on display (of course).
Is there any possibility to do something like this in my ino file:
#define MY_DISPLAY_1
and then, in the file "User_Setup_Select.h" put something like this:
#ifdef MY_DISPLAY_1
#indclude <MY_DISPLAY_1.h>
#endif
I actually tried it but apparently it is not working - complaining too much - apparently such directive is messing around
If such mechanism exists, I would never ever mess up with my projects.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions