Here is a very simple way to reuse code placed in lib/
from different single-file main
apps. My file tree looks as follows:
$ tree
.
├── lib
│ └── ...
├── platformio.ini
└── src
├── board.h
├── main-blink.cpp
├── main-getiq.cpp
├── main-lcd.cpp
├── main-psram.cpp
├── main-qspi.cpp
├── main-wifi.cpp
└── memtest.h
And the platformio.ini
has something like this:
[env]
platform = ststm32
framework = cmsis
board = disco_f723ie
src_filter = +<*.h> +<main-${PIOENV}.cpp>
...
[env:blink]
[env:getiq]
[env:lcd]
[env:psram]
[env:qspi]
[env:wifi]
Note that the [env:xyz]
sections can be left empty.
It’s by far the simplest way I’ve found so far to keep a collection of little test & demo apps in a single place, all compiled in the same way and using the same library code. A quick check that all the apps compile is a matter of typing pio run
.
To build and upload say the blink
app, type: pio run -t upload -e blink
- easy!
(and if you define alias prue='pio run -t upload -e'
, then this becomes prue blink
)