esp32-lightbar/src/main.py

27 lines
433 B
Python
Raw Normal View History

2021-12-28 22:10:27 +01:00
# main.py -- run after boot.py
import _thread
import time
def count(name: str, stop: int = 10):
i = 0
while True:
print("[{}] {}".format(name, i))
i += 1
if i > stop:
break
time.sleep(1)
print("[{}] exit".format(name))
# Start some threads
_thread.start_new_thread(count, ('thread1', 5))
_thread.start_new_thread(count, ('thread2', 3))
# Main thread
count('main', 10)