Hello everyone,
Not sure if on-topic enough, but I need some math help for my project using the FastLED library.
My project is set up such that each routine is called by a scheduler. One call will generally advance the LEDs 1 step. Now I have one routine which spins around a lit up LED on a Adafruit 60 ring. I’d like it to reach leds[0] every 0.5 seconds, so at 120BPM. Now the scheduler task interval for calling the routine needs to be a little faster than the round-trip time (of the led around the ring).
So the LED does 1 revolution every 500 milliseconds, but the scheduler needs to run at about 450 milliseconds to reach the correct speed.
I’ve been twiddling with various math to try to get it to converge, and I have a working solution, only it’s too slow, it takes over 100 loops of the LED to synchronize.
Here’s the LED routine calling the syncToBPM() function: https://github.com/costyn/GFPM-Ring/blob/master/GFPM_LEDRoutines.ino#L328
And the function syncToBPM(): https://github.com/costyn/GFPM-Ring/blob/master/GFPM_LEDRoutines_helpers.ino#L230
The scheduler time is specified in microseconds while I check the timing in milliseconds. Microseconds to make the sync more accurate, but it doesn’t make it less confusing 
I have a spreadsheet with some sample numbers too: https://docs.google.com/spreadsheets/d/1FrRPmQY59nuD-N_Kn1iE3-FbfXlnip_T61PLhEWJnpo/edit#gid=0
Tips and/or solutions welcome 
EDIT: yes, I know about beat8 and beatsin8, love it! It would be trivial to make this using beatsin8, but this is a just a simple example. I use the syncToBpm() in other routines too, ones which aren’t as easily rewritten.