Keep light on using thread
1 2 import e32, miso, thread 3 running = 1 4 def lighton(): 5 while running: 6 miso.reset_inactivity_time() 7 e32.ao_sleep(5) 8 9 thread.start_new_thread(lighton, ()) 10 # end by set running = 0
2 functions (lighton, lightoff) version.
1 2 import e32 3 import miso 4 import thread 5 6 flag = 1 7 def _lighton(): 8 while flag: 9 miso.reset_inactivity_time() 10 e32.ao_sleep(5) 11 12 def lighton(): 13 thread.start_new_thread(_lighton, ()) 14 15 def lightoff(): 16 global flag 17 flag = 0