Hi Guys
I'm starting work on a new project controlling LED via an ESP8266. I'm very new the world of Arduino and still finding my feet.
The project I'm working on is controlling and syncing LEDs with FXs runf from the ESP
The concept
I'm not going to go into every detail otherwise this post will be pages long. Each ESP will have a set of LEDs attached to it, it will have the same code on each one (syncing of user data via UPD). With all the data synced on each ESP, one of the ESPs will be the master, this will tell the others what FX to run and when via UPD.
There will be a web interface where I can edit and trigger the FXs, or build shows, all settings stored in a JSON on SPIFFS. If I trigger an FX, this needs to do 2 things, first it needs to send a command to all the others units to run this FX, the second run that FX.
If I build and run a show, when the show is triggered, has to do a number of things.
- Load the show information
- get the first FX in the show, send command to all the other units to load and run the 1st FX
- run that FX itself until the set number of loops and then move to the next FX, and tell the other units to do the same.
- repeat
My first thought was for speed, load all the FXs and Show data into some arrays and use them. I can not do that, as the arrays would be to big, some would have to be a 10 multidimensional.
Here's the kick, when running a show there can be an offset, what this will do is delay each FX on the units, eg if I trigger FX1 with a 1 second offset, the master one will trigger straight away, the 1st unit 1s later, the 2nd unit 2s later and so on.
The master will know about all of the connected units as they will hand shake with it on power up.
I have 2 choices.
-
Send out the data in real time to each unit. This may be tricky to manage as there would be unknown number of units connected. and with the offset of each unit means building frames of data, with complicated timings for each unit so they get the correct frame of data in the right order and sending the lot in real time.
EG if there are 10 units, each unit having 20 pixels on it, means there are 20 frames of data for each FX, so with a zero offset time it has to create 10 frames of data and sent them at once, simple
With an offset in place it gets really complicated. Let say I have a 1 second offset, and the FX takes 2 second to run, that's 10 frames per second. This means the master will run 10 frames itself, and on the 11th frame send the 1st frame to the 1st unit, then 12th frame send the 2nd frame to the 1st unit, by the time you get to the 5th unit, the master unit has started again, and at this point you are in a right mess of keeping tracks things. -
Just send out a global command, within that command is an identifier of each unit (probably the mac address). This will tell each unit to go load the FX with the required settings, wait the X offset time and then run it, it will continue to run it until is told otherwise.
I have 2 concerns with this, first will they keep in time or drift, not sure how good the clocks are? As I will not be able to load the FX data into arrays on power up, each unit (inc the master) will have to go off, read the details of the SPIFFS, create and run its own FX in real time (this is why they are all synced).
In theory as the global command is sent first and should be really fast, they all start loading the settings off the SPIFFS at the same time, so any delays will be present on all units
Having little experience with Arduino I wanted to bounce this idea of you guys before I stated coding and end up digging a hole for myself.
I'm open to any suggestions or ideas on the best way to approach this.
Thanks in advance
Brian