Game of Life's slow frame rate is maybe due to scanForTouch()
nbogie opened this issue · 1 comments
scanForTouch() apparently takes 100 milliseconds, according to the source code:
// This whole procedure should take about 100 milliseconds
bool EverydayCalendar_touch::scanForTouch(){If that's accurate, the best frame rate you could possibly hope for would be 10FPS even if the rest of the code took no time.
Suggested solutions:
ideal:
Find a fast way to check for touch - interrupt-based?
naive:
instead of scanForTouch every frame, do it only one in 5 or one in 10 "frames". However, that will give us an unpleasant irregular frame duration. (e.g. 4 fast frames, 1 slow, etc)
better:
Model two modes: a "pattern programming" mode and a "run simulation" mode. In pattern programming mode, you'd scanForTouch every frame to be nice and responsive to touch - we don't care about the slow frame rate when programming patterns.
In "run simulation" mode, however, only scan for touch rarely (e.g. once every 5 seconds?) - the user will have to hold a button down for a while to get out of simulation mode and back into pattern programming mode.
This would still give us one slower frame every 5 seconds but hopefully that's not too noticeable.
Maybe check only one key to get out of "run simulation" mode, if it's significantly faster to check one key for touch than all.
I guess I'm wrong - the bouncing balls sketch clearly has a good frame rate despite the fact you're doing scanForTouch in each iteration of loop