DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Keep Light On Using Thread

03.11.2006
| 6282 views |
  • submit to reddit
        Copy-paste version
import e32, miso, thread
running = 1
def lighton():
  while running:
    miso.reset_inactivity_time()
    e32.ao_sleep(5)

thread.start_new_thread(lighton, ())
# end by set running = 0

2 functions (lighton, lightoff) version.
import e32
import miso
import thread

flag = 1
def _lighton():
    while flag:
        miso.reset_inactivity_time()
        e32.ao_sleep(5)

def lighton():
    thread.start_new_thread(_lighton, ())

def lightoff():
    global flag
    flag = 0