Config files in PROS

Hopefully this is a simple question but does anyone know if you can use config files (be it plaintext, json, yaml, etc.) in PROS? For example keep all of my motor information in one config file so its easier to edit than trying to look through my declarations.
My alternative is using header files and just define each value which I don’t see any major problems with.

it’s not supported in that you can’t just upload a file to the brain and have the program read it’s however there’s a couple other things you could do

  • put your config files on the SD card and read them with something like nlohmann/json
  • add some logic to your makefile that either runs a script or directly reads some config file (maybe another .mk file) and passes preprocessor macros to the compiler (e.g. by adding -DVAR="VALUE" to cppflags
  • probably others i haven’t thought of because it’s late but hopefully those are enough to get you started

Well, a dedicated header file is a config file, albeit with somewhat specific syntax.
Anything wrong with that?


I assume user is attempting to create some form of GUI for his PROS project, so they can configure their motors graphically.

1 Like

SD card should work. Just curious - not necessary but - can the brain write json to the SD card or would that have to be done on a separate device? The idea being that we can adjust our ports, controls, etc from the brain instead of having to use a different device.
I’m currently using header files as config and it works but we have to recompile and re-download the code each time we change something.

You can write whatever you want on the SD card, you just need to have a way for the program to read it. You can probably find a json parsing library to do it for you, like the one linked in hotel’s first post on this thread.

That’s what I’m using right now and it works but I would like to avoid recompiling the code when we have to change something. Another answer mentioned using the sd card in the brain which is probably what I will go with.

Thanks. Do you know the best way to go about loading types that aren’t supported by json (ie controller buttons or motor gearsets). My first thought is a switch/case or something like that and use supported types in the config file.

I would assume that would be the best option. You could use numbers in the json as IDs that correspond to things like buttons, then just do a switch like you said.