Go Down

Topic: Board Settings in *.ino file (Read 28558 times) previous topic - next topic

GeertVc

Well, it's pretty clear by the degree of support that I'm the only one who thinks this would be a good feature to incorporate into the IDE, so it's probably best to just forget that I posted this suggestion.
No, you're not and no, it's not...  I'm having the same question since I also have the very same issue. Trust me, we're not the only ones.

To me, it would be normal and logically if the board could be saved with the .ino file of a project since having different boards laying on your table is really not an exception.

I have different Arduino's, ESP8266 and ATTiny85 boards with which I'm working and each and every time I'm hitting the same stone (must be stupidity, I guess): forgot to change the board and bang... building is OK but uploading is, of course, not...

Hope this will change in the future.

Best,

Geert

technix

Instead of using comments, I think using #pragma might be a better idea. The #pragma's would be picked up by the arduino-build tool and removed from the generated C++ sources. It is also technically backwards compatible since GCC will just ignore the unrecognized #pragmas.

Ideas I have:

Code: [Select]
#pragma arduino board "Arduino/Genuino Uno" // This selects the board in the sketch.
#pragma arduino board "Generic ESP8266" // You do meed to match the board title or identifier exactly though.
#pragma arduino upload programmer // Force uploading with programmer
#pragma arduino upload default // Default upload method.
#pragma arduino define SOME_VARIABLE // Passes -DSOME_VARIABLE to all calls of GCC
#pragma arduino import TFT // Pulls in a library without including its header file. There might be C++ header file collisions in some corner cases, and this alternative syntax can avoid that.
#pragma arduino config board.upload.arguments "-F" // This can even inject board.txt contents.

vaughang91

anyone have any luck with this ?

ThingEngineer

The #pragma idea is an excellent idea technix.

I try to use Atom PlatformIO when possible but I still use Arduino a lot. In PlatformIO all the settings are in an ini file, it's wonderful when you are working on multi-device setups. I would love to see this in the Arduino IDE as well!

david_van_brink

I grepped the interweb for this topic and landed here.

Yes please. #pragma or something to set the board type!

I wonder where the "current settings" are stored; a tacky workaround could be to always launch Arduino.app from a command line script that read the .ino and munged the app prefs file.

DetAmend

Bumping this one - my filename normally includes the Boardtype. That would be a great improvement!

tarbear123

Will ide save the board settings?

pert

FYI, the Arduino Web Editor does already have this feature. The board and port association is saved in a metadata file named sketch.json.

PerryBebbington

I found my way here as I'd like the same thing too. I'm always bumping into this, compiling for the wrong board because I'm working on a different project. I take no one's implemented a solutions? Of the suggestions, the #pragma idea seems best.

SteveMann

It's De-ja vu all over again.
I'll respond to the OP observation that there doesn't seem to be much interest in this feature.  Yes, there is much interest in this feature, and it's been asked for frequently over the years.  but the developers haven't shown any interest in implementing it, or to even reply why it can't be done.

Right now, I have an Arduino Uno R3 and two Wemos D1 Mini's on my bench.  They are all for a single project and you can bet that I have compiled for the wrong board at least two or three times a day.
Fritzing pictures are NOT schematics. I don't speak Fritzing.

Please do not ask for help by PM. I will not respond. If you need help, post a question on the appropriate forum.

Click on Add Karma if I helped you.

pert

arduino-cli has a "board attach" feature, which lets you associate a board and port to a sketch. The Arduino IDE will eventually be switched to using arduino-cli. So I think this feature is indeed being worked on by the Arduino developers. They're just doing it in a way that is consistent with the long term plans, rather than spending time implementing the feature into the Arduino IDE or arduino-builder, where it would just end up being thrown away as soon as the transition to arduino-cli happens.

Hiddenvision

I know this is an old thread but seems like the subject is still valid.
I let out a program for windows to do a bit of preference file shuffling before the INO is loaded.

https://forum.arduino.cc/index.php?topic=629619.0


mnewman

I have a similar problem.

My real issue is that there are some preferences that are specific to the project that I would like to set and archive with the project. (for example the processor to use or how much RAM is used for file storage). The idea of putting the preferences.txt file into the project directory allows archiving the preferences properly, but, as mentioned in a previous reply has the problem that compiling for a different platform will now have too many settings. Some preferences like "editor.external=true" do not belong to the project.

A better solution would be to put another preferences.txt file in the project directory that contains only the preferences specific to the project at hand. There already is system level preferences.txt file and a per user preferences.txt file. Adding one for the project taken from the same directory as the xxx.ino file would be an elegant solution to this problem.

Hiddenvision

Still not found a suitable built in method.
My preference file switcher still works perfect for my needs.

Adrianotiger

#29
Jan 09, 2020, 08:06 pm Last Edit: Jan 14, 2020, 02:36 pm by Adrianotiger Reason: link to GitHub
I have this problem too. Developing for Arduino, Tiny, ESP, Teensy and Core 328...

I wrote my application to start the Arduino with the right settings.

How it works:
- Once you start your Arduino IDE, select the board and set all preferences.
- Launch application
- Click on a sketch (or import one) and select the preferences you want to save - application will try to auto-detect the right preferences
- If you click "save preferences", it will create a ".preferences.txt" inside your project folder
- from now, every time you start the application, it will merge the current preferences with your custom preferences and start the Arduino IDE

Note: If you start with the custom settings, any changes made on your IDE will not be saved as the preferences will be generated in a temporary folder. I can improve this feature.

Edit: The application can be downloaded from the GitHub repository: https://github.com/Adrianotiger/ArduinoIDE_Launcher

Go Up