Parameterizing project using config file


I’m building a platform which is intended to send telemetry data from a radio-controlled plane to a ground station, which works pretty well already.
However now I have the problem that I do not want to hardcode the specific hardware. It would be great to just have a config file that specifies “Sensor X is connected to pins ABCDE” and then have a build process which chooses the right implementation.
The current way is not very satisfying: I have a branch for each different kind of hardware-unit.
Here you can find the current code: GitHub - peteole/telemtryFirmware

What do you think is the best way to solve these problems?

You are already using build_flags to inject macros in the build process via the platformio.ini – why not inject a macro that will let your code detect what pins to use? That can e.g. be directly the pin number.

If you have multiple board configurations you should write that as multiple platformio.ini environments. Each environment will produce then one firmware according to the settings defined in it. Environments can share / pull in data from other environments (commonly a common_env environment) so you don’t have to repeat yourself as much. See examples displayed in our documentation.