I’m relatively certain I’m going to kick myself for asking this; I’m sure I know how to do this but I’m probably just not putting together the pieces. I’d like to be able to access values from the platformio.ini file within my sketch’s macros. Something like:
This seems to be the prime example for the usage of build_flags. E.g., doing
build_flags = -D BAUD=115200
Will make the macro BAUD with a value of 115200 visible to every codefile in the project, so you can do Serial.begin(BAUD); in the code. Of course macros can be chained, so e.g.
Follow-up: I thought that worked but I was mistaken. I went back to the following in platformio.ini:
build_flags = -D monitor_speed=115200
And the following in my sketch:
#define BAUD monitor_speed
Serial.begin(BAUD);
I’d like to define the speed once, but this is much better than having to put it both in the sketch and in the ini. My end goal here is a template sketch that I can spin up quickly for testing.