Board settings in sketch? #718
Replies: 3 comments 2 replies
-
I have used features described on this page to cater for different chips in my sketches. |
Beta Was this translation helpful? Give feedback.
-
You cannot do that. The submenu options are specifically used for cases where the rules of C++ stipulate that that is forbidden, namely, you cannot have a preprocessor directive in one compilation unit (like the .ino.cpp file) that is propagated to another compilation unit (like, say, TWI.c where you need to know whether it's in Master or slave or Master and Slave mode) A #define before including a file will impact only that compilation unit, so if I
The rest of the sketch will see the results of that headerbeing preprocessed with USE_SPECIAL_MODE included. But in the C file that does the work, library_defaulting_to_non-special.c - it will not see the USE_SPECIAL_MODE define and will turn that library into something different. But if a submenu option was used to set USE_SPECIAL_MODE via adding the -DUSE_SPECIAL_MODE directive, that would get called for all compilation units, and they'd both be able to see it, and things would work. The submenu options set variables which can be used as command line options. And that's how we achieve seemingly impossible things like controlling how builtin libraries work even if the change needs to be atthe preprocessor level, not the compiler level, as it often has to be. The other case they're using in is to control fuse settings. Fuse settings are not even looked at by the compiler, but rather only at upload time. And so there's no real way to put those into the sketch either. So No, this is not possible, The submenus are used when tthey are the only way to get the desired behavior. I would love to have a way for people to specify the sketch configuration without having to use the stupid dropdown menus,. I know nobody likes, them, but they dislike tlosing the functionality even more. If there was a way to get Arduino.h to #include a properties.h file FROM THE SKETCH LOCATION IF AND ONLY IF it was present and otherwise continue on without a warning that would be grand, but as far as i know there isn't such a thing in C, and more than a massive particle can exceed the speed of light in a vacuum within our universe. Within other languages, there was easy ways, and within other universes, superluminal travel may be possible. But we're living in this universe writing C++. so I don't believe we can do this. |
Beta Was this translation helpful? Give feedback.
-
I just signed up so of course I'm all super keen to prove myself "useful". :D |
Beta Was this translation helpful? Give feedback.
-
This is likely an IDE question, but is there any way to put board settings (from the tools menu) into the sketch?
Maybe there's a smarter way, but I have a few different designs that use different chips, frequencies and timer settings and setting them all manually when I switch between sketches is a little prone to memory oopsies.
Is there some trick?
Beta Was this translation helpful? Give feedback.
All reactions