Archomeda/lightfx-extender

Updates to lights should happen at a regular and same interval

Closed this issue · 1 comments

The lights of each device are being updated on a separate thread, which is good. But every time it completes one update (given that there's an update directly happening after that) it sleeps for 5ms before resuming. While this is good for short loops, this loop isn't short at all and might cause to stall updates and give a noticeable "stuttering" of color changes. To be clear, it's not a slower color transition (meaning it takes 2 seconds for a color transition instead of 1), but rather a color jump instead of a more smooth transition.

For example:

  • Device A takes 2ms to update the lights, and sleeps for 5ms. This takes 7ms for each update.
  • Device B takes 4ms to update the lights, and sleeps for 5ms. This takes 9ms for each update.
  • Device C takes 12ms to update the lights, and sleeps for 5ms. This takes 17ms for each update.

It's better to have an update every 5ms (which was intended) instead of extending an update time with 5ms. This way device A and B can have updates every 5ms (which is possible). Device C is still too slow for having it to update every 5ms, so it should just have to settle with an update every 12ms, the same amount it takes for it to update the lights.

After this has changed, it's probably a good idea to review if having an update every 5ms is good enough, or maybe too fast (it is 1/200th of a second after all). It's possible to expose it as a configuration in settings.json to let users decide what they want.

I'm leaving it unexposed for user configuration. Although it seemed useful at first, it really isn't when I was thinking a bit more about it.