I've got a working prototype of a project for a model railway that I'm writing, and now I want to make it more organised.
I'm a python dev, so I'm used to organising my code in classes etc, and I'm now looking to turn my arduino project towards a similar approach.
The project involves a number of physical "modules" (ESP8266-based in my case) that connect via MQTT over WiFi and flash LED's, operate servos, or switch relays
I'm writing a library to bundle the wifi/MQTT connections into a reusable space, however I'm now thinking that as all the modules will be based on the same chip is it worth bundling the various classes and functions that will drive the motors/servos into the same library or a different one?
As an example, I'll have a number of signals on my layout controlled by servos. There will also be "animations" on the layout from LED's (fires flickering in houses etc).
At the moment, the code looks a bit like this:
rail_control.ino |_ #include "controller.h" |_ WiFiSetupAndControl(ssid, password) |_ MQTTSetupAndControl(esp_client) |_ SignalControl(signal_state) |_ LEDControl(pattern, delay_between_state_changes)
I'm wondering if it's worth splitting SignalControl and LEDControl out into their own separate libraries, or at least into dedicated files given that "controller.h" is now well over 500 lines long, but I'm not sure how I'd best do that in this language!
Any help appreciated, especially if it's links to example projects where this has already been done.
I've looked at platform.io, and I'm still not ruling it out, but it does seem overkill when I'm going to be deploying to the same hardware platform for all the devices.