Skip to content

Instantly share code, notes, and snippets.

@anoken
Last active September 3, 2020 11:09
Show Gist options
  • Save anoken/4ee9daafc5b2892405b65ded2a56e29c to your computer and use it in GitHub Desktop.
Save anoken/4ee9daafc5b2892405b65ded2a56e29c to your computer and use it in GitHub Desktop.
190924_thread_test_maixpy.py
## @anoken
## MaixPy Thread Test
## MicroPython v0.4.0-50-gcafae9d
import lcd
from Maix import GPIO
from fpioa_manager import fm
import _thread, time
lcd.init()
lcd.clear()
Lock = _thread.allocate_lock()
def testThread():
cnt=0
while True:
time.sleep_ms(100)
lcd.draw_string(0,20,"cnt1:"+str(cnt))
cnt+=1
def testThread2():
cnt2=0
while True:
time.sleep_ms(100)
lcd.draw_string(0,50,"cnt2:"+str(cnt2))
cnt2+=1
def testThread3():
cnt3=0
while True:
time.sleep_ms(100)
lcd.draw_string(0,80,"cnt3:"+str(cnt3))
cnt3+=1
_thread.start_new_thread(testThread,())
_thread.start_new_thread(testThread2,())
_thread.start_new_thread(testThread3,())
print("done")
@ChahidTALHA
Copy link

Hi sir, i was trying to implement your code to start practicing the multi-threading using Sipeed maixduino,
First I tried to customize the firmware and added the _thread the module and burn it to flash.
The problematic is that i get nothing displayed on the LCD and the code finishes execution ( doesn't hold on while loop).
can I get any help about that ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment