Last active
September 3, 2020 11:09
-
-
Save anoken/4ee9daafc5b2892405b65ded2a56e29c to your computer and use it in GitHub Desktop.
190924_thread_test_maixpy.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## @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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ?