DISCLAIMER
This is kind of an advanced setup, and will be very hard to keep on track for a newbie.
So this is not for people just starting out with C/C++, microprocessor programming or PlatformIO.
In the latter case, please begin at PlatformIO:s tutorials and try out some easier stuff first. No offence.
One of the many great things about PlatformIO is its ability to have projects
that build and run on several platforms simultaneously. This shows how this is done.
It provides a starting point for those who need it and runs on:
- Platforms
- Native
- ESP-IDF
- Arduino
- Hardware
- PC (Linux/MacOs/Windows)
- LILYGO® TTGO LoRa32 V1.0 SX1276/SX1278
- LILYGO® TTGO T-Beam V1.1 ESP32 LORA SX1262
- Arduino Uno Rev3
It has:
- One runnable main.c for all platforms
- Unit testing
- Local on the native platform
- And running on the boards
- a Kconfig implementation to help you hold your config even if you don't use ESP-IDF.
All changes are, hopefully, in platform.ini
- Change the serial id:s to your own:
/dev/cu.wchusbserialNNNNNNNNN
You'll find it in PIO Home - Devices
(no, the serial ids of my test boards are hardly attack vectors) - Add your own board's configuration in an
[env:yourboard]
-section - Go do great things!
- The build times are very different for the different platforms.
- Arduino don't have to have a
main.cpp
.. - ..because we only need .cpp when we need c++ features
likeSerial.begin(9600)
for Arduino to be able to log. - Config
platformio.ini
- Both Arduino and Native needs lib_extra_dirs = components
- Native platform need
lib_compat_mode = off
.
I am have not found out why for sure. Any ideas?
- If you want a command run in all environments, look in the "General" project task group.
- There is a /development folder, take a look.