Hi everyone,
Here it is, I want to make several nodes with shared code but of course they need to be upload to differents boards. What would be the best practices.
- Make the share code as library and keep all node separate.
- Put all in one project and use src_filter which for me start to be a mess and was working only with cpp
- Other solution I did not think about.
Thanks for your help !
Clément
Hi,
This is one of the tasks for the which PlatformIO was developed - to build the same code for multiple targets/development platforms. I prefer 1-st option where a code is organized into multiple libraries/components/modules. It’s good for testing and debugging.
Also, if you need some additional control between nodes within main source code, you can use extra macros (defines). For example:
[env:node1]
build_flags = -DMY_NODE_1
[env:node2]
build_flags = -DMY_NODE_2
Then, in the source code
#ifdef MY_NODE_2
// some code, includes, etc
#else
// ...
#endif
Yeah good tips thanks. I think I will go this direction too.