-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial_pico.py
40 lines (28 loc) · 897 Bytes
/
serial_pico.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import select, sys, time, machine
import lcd_pico
from sys import stdin
import uselect
led =machine.Pin(25, machine.Pin.OUT)
led.value(0)
class pc_driver():
def __init__(self, handshake_key):
self.data_length = 16
self.handshake_key = handshake_key
self.handshake_len = len(self.handshake_key)
def recieve_data(self):
select_result = uselect.select([stdin], [], [], 0)
buffer = ''
return select_result, buffer
def data_to_string(self):
recv_result, recv_buffer = self.recieve_data()
while recv_result[0]:
recv_char = stdin.read(self.data_length)
return recv_char
screen = lcd_pico.lcd()
driver = pc_driver("HANDSHAKE")
while 1:
data = driver.data_to_string()
if data:
screen.display((0,0), data)
data = None
break