Best practices to organize projects

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.

  1. Make the share code as library and keep all node separate.
  2. Put all in one project and use src_filter which for me start to be a mess and was working only with cpp
  3. Other solution I did not think about.

Thanks for your help !



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:

build_flags = -DMY_NODE_1

build_flags = -DMY_NODE_2

Then, in the source code

#ifdef MY_NODE_2
// some code, includes, etc
// ...

Yeah good tips thanks. I think I will go this direction too.