Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prebuild script to use additional build options #8095

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions doc/faq/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,41 @@ Artificially clearing them is a workaround to help saving precious heap.

Ref. `#1923 <https://github.com/esp8266/Arduino/issues/1923>`__

Use custom defines from build options file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A file named ``build_opt.h`` next to the ``sketch.ino`` file enables the user
to specify custom definitons in a central and organized location.

The following code is a slightly modified Blink example sketch. It opens the
possibility to define the ``WAIT_TIME`` between the LED state changes. If no
``build_opt.h`` file is placed next to the sketch file, the default value will
be set as 1000ms in this example.

.. code:: cpp

#ifndef WAIT_TIME
#define WAIT_TIME 1000 // use 1000ms if not defined different
#endif

void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(WAIT_TIME);
digitalWrite(LED_BUILTIN, LOW);
delay(WAIT_TIME);
}

Place the following content in a file named ``build_opt.h`` at the same
location as the ``sketch.ino`` file to define the ``WAIT_TIME`` to 500ms.

.. code:: cpp

-DWAIT_TIME=500
earlephilhower marked this conversation as resolved.
Show resolved Hide resolved

Why is there a board generator and what about it ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down