Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 25 of 32

Thread: HOWTO: Store Projects settings (like F_CPU, USB, Keyboard-layout)

Threaded View

  1. #1
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679

    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)
    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() {}
    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/38533...l=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





    Attached Files Attached Files
    Last edited by Frank B; 09-19-2018 at 06:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •