Closed xmenxwk closed 8 years ago
The library started out with pins being specified from the sketch, but this was a real pain for users because if they used different pins to me they had to edit all 26 example sketches and save a copy before they could run them. If they changed the pins they had to go through the whole process again. The User_Setup.h approach takes this hassle away. I need to be able to specify the different fonts to load at compile time and other project specific settings too for my projects.
As User_Setup is a header file you can put something like this at the start of the file:
//#define project2
Then use #ifdef to set the pins. So you only need to add/delete // and you can then run any example sketch on each project without any changes to those examples,
The other way (which I use) is to have multiple copies of User_Setup.h (Project_1.h etc) with different names, then edit the very first #define (deliberately the first!) in the TFT_ILI9341.h header file to call up the user/project specific settings file.
This means each project can have all the other settings (fonts etc) in the file different too.
Having said that, "one day" I will add the option to set pins from a sketch that will over-ride the User_Setup file. But this would take me more time to do and test than the time I spend making the occasional quick edit of the User_Setup file, so that never got done.
I do not understand why pin numbers aren't allowed when initializing. Updating User_Setup.h is not that good. Imagine this, if I have 2 projects, both using different pins. Now I have to keep edit the pin numbers for each different update.