HOWTO: Store Project Settings
- Advanced users only -
I found a way to store project-settings.
Why ?
I often need different setting for projects, and often I forget to select the correct options in the IDE.
The following shows a way to store them on a per-project-basis.
For example: A Sketch needs - or works best - with F_CPU=144Mhz
Howto:
Copy the attached platform.txt to Arduino\hardware\teensy\avr\platform.txt (overwrite the existing, but make a backup before)
- It adds the following command to the commandline of GCC:"@{build.path}\sketch\defs.h"
- If the file does not exist, it writes an empty defs.h to prevent error-msgs during compilation
Create a file "defs.h" in your project-directory (where the .ino file is)
Example file: (overrides the F_CPU setting)
- The first line undefines the existing definition
- The second line defines a new F_CPU (144MHz in this case)
You're done.
Sketch-example:
1. Create the mentioned defs.h file above in the same directory.
2. Compile the sketch with - for example 24MHz - and watch the output.
The file-extension ".h" is not the best - i tried an other one, but it did not work (the file was not copied to the build-directory)
(ideas?)
In the attached platform.txt is a line:
recipe.hooks.sketch.prebuild.1.pattern.windows=cmd /c if not exist "{build.path}\sketch\defs.h" "echo.>{build.path}\sketch\defs.h"
[edit]We need one more line for MAC:
recipe.hooks.sketch.prebuild.1.pattern.macosx=
Would be great if someone can test this and says "Yes, works!"
EDIT: Replaced platform.txt with a non-TYQT-version
EDIT: Find platform.txt for Arduino 1.8.5 in this post: https://forum.pjrc.com/threads/3853...yboard-layout)?p=172835&viewfull=1#post172835
EDIT: Find platform.txt for Arduino 1.8.7 in this post: https://forum.pjrc.com/threads/38533-HOWTO-Store-Projects-settings-(like-F_CPU-USB-Keyboard-layout)?p=187712&viewfull=1#post187712
- Advanced users only -
I found a way to store project-settings.
Why ?
I often need different setting for projects, and often I forget to select the correct options in the IDE.
The following shows a way to store them on a per-project-basis.
For example: A Sketch needs - or works best - with F_CPU=144Mhz
Howto:
Copy the attached platform.txt to Arduino\hardware\teensy\avr\platform.txt (overwrite the existing, but make a backup before)
- It adds the following command to the commandline of GCC:"@{build.path}\sketch\defs.h"
- If the file does not exist, it writes an empty defs.h to prevent error-msgs during compilation
Create a file "defs.h" in your project-directory (where the .ino file is)
Example file: (overrides the F_CPU setting)
Code:
-UF_CPU
-DF_CPU=144000000
- The first line undefines the existing definition
- The second line defines a new F_CPU (144MHz in this case)
You're done.
Sketch-example:
Code:
void setup() {
delay(1000);
Serial.println(F_CPU);
}
void loop() {}
2. Compile the sketch with - for example 24MHz - and watch the output.
The file-extension ".h" is not the best - i tried an other one, but it did not work (the file was not copied to the build-directory)
(ideas?)
In the attached platform.txt is a line:
recipe.hooks.sketch.prebuild.1.pattern.windows=cmd /c if not exist "{build.path}\sketch\defs.h" "echo.>{build.path}\sketch\defs.h"
[edit]We need one more line for MAC:
recipe.hooks.sketch.prebuild.1.pattern.macosx=
Would be great if someone can test this and says "Yes, works!"
EDIT: Replaced platform.txt with a non-TYQT-version
EDIT: Find platform.txt for Arduino 1.8.5 in this post: https://forum.pjrc.com/threads/3853...yboard-layout)?p=172835&viewfull=1#post172835
EDIT: Find platform.txt for Arduino 1.8.7 in this post: https://forum.pjrc.com/threads/38533-HOWTO-Store-Projects-settings-(like-F_CPU-USB-Keyboard-layout)?p=187712&viewfull=1#post187712
Attachments
Last edited: