Hi, I’m new to platformio.
I am trying to figure out how to add some extra flags to my platformio.ini file by importing them from an external file, similar to how #include works in c.
I’ve spent a while searching the docs and forum, but just getting myself confused about sections and envs etc
#include <Arduino.h>
int x = MY_TEST_LOCAL_DEF;
int y = MY_TEST_EXTERN_DEF;
void setup() {}
void loop() {}
When I compile it says MY_TEST_EXTERN_DEF is undefined, so it’s not seeing the included file. Obviously I have a lot to learn, but was hoping someone would point me in the right direction.
Now, the compiler finds the external def, but not the one in platformio.ini.
The docs indeed say that if the group name matches they will be overwritten, although I assumed that just meant any flags of the same name, not that it would erase all of the flags and only use the external ones.
But it seems I have to use the same group name in the external file or my code doesn’t see the entries anyway.
Is there a way to have both sets of flags visible to my code?
#include <Arduino.h>
int x = MY_TEST_LOCAL_DEF;
int y = MY_TEST_EXTERN_DEF;
void setup()
{
Serial.begin(115200);
Serial.printf("Vals = %d, %d\r\n", x, y);
}
void loop() {}
Result:
Vals = 22, 33
I don’t know if this is the only / best solution, but it’s doing what I want.
This allows me to compile for a variety of custom boards with different pinouts by only changing one ot two lines in the platformio.ini file.