Skip to content

Commit 286cc4c

Browse files
add documentation for build_opt.h file to the faq readme
1 parent 5c0f07f commit 286cc4c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

doc/faq/readme.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,41 @@ Artificially clearing them is a workaround to help saving precious heap.
152152
153153
Ref. `#1923 <https://github.com/esp8266/Arduino/issues/1923>`__
154154

155+
Use custom defines from build options file
156+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157+
158+
A file named ``build_opt.h`` next to the ``sketch.ino`` file enables the user
159+
to specify custom definitons in a central and organized location.
160+
161+
The following code is a slightly modified Blink example sketch. It opens the
162+
possibility to define the ``WAIT_TIME`` between the LED state changes. If no
163+
``build_opt.h`` file is placed next to the sketch file, the default value will
164+
be set as 1000ms in this example.
165+
166+
.. code:: cpp
167+
168+
#ifndef WAIT_TIME
169+
#define WAIT_TIME 1000 // use 1000ms if not defined different
170+
#endif
171+
172+
void setup() {
173+
// initialize digital pin LED_BUILTIN as an output.
174+
pinMode(LED_BUILTIN, OUTPUT);
175+
}
176+
177+
void loop() {
178+
digitalWrite(LED_BUILTIN, HIGH);
179+
delay(WAIT_TIME);
180+
digitalWrite(LED_BUILTIN, LOW);
181+
delay(WAIT_TIME);
182+
}
183+
184+
Place the following content in a file named ``build_opt.h`` at the same
185+
location as the ``sketch.ino`` file to define the ``WAIT_TIME`` to 500ms.
186+
187+
.. code:: cpp
188+
189+
-DWAIT_TIME=500
155190
156191
Why is there a board generator and what about it ?
157192
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)