cyberbit / neoblock

Alternative TiX clock on NeoPixels.
https://cyberbit.github.io/neoblock
3 stars 0 forks source link

Move graphics functions to threads #6

Closed cyberbit closed 7 years ago

cyberbit commented 7 years ago

This will keep the client responsive. Will need to test command overlap when running animations.

cyberbit commented 7 years ago

Command overlap causes weird graphical glitches and eventually failure of the device. Will consider using a queue to schedule graphics commands, or implementing a singleton policy that cancels the currently running thread if another is requested.

cyberbit commented 7 years ago

Command overlap is pretty much solved in the next commit. Only one graphics thread runs at a time, synchronized by a global thread ID variable. When a thread is started, a random ID is stored globally. During the critical section (frame loop), the current thread ID is checked against the global ID. If they do not match, the loop is skipped, and eventually the thread is cleaned up and stopped.