Using Ao_timer For A Better Sleep
Join the DZone community and get the full member experience.Join For Free
A few of my old examples include 'unsafe' use of e32.ao_sleep(). The problem is that the sleep can't be interrupted. I often use a convenient loop like this
while running: // do something e32.ao_sleep(1) # sleep a secNow in pys60 1.3.1, it's better to use e32.Ao_timer
timer = e32.Ao_timer() while running: // do something timer.after(1) # sleep a secI can then interupt the sleep with
timer.cancel()in other part of the program if I need to continue the loop. For example, I can end the application without waiting for the last second.