Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Keep Light On Using Thread

DZone's Guide to

Keep Light On Using Thread

·
Free Resource
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

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}