-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui-main.py
51 lines (42 loc) · 997 Bytes
/
ui-main.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
41
42
43
44
45
46
47
48
49
50
51
import driver
import math
from pynput.keyboard import Key, Listener
device_name = '/dev/ttyACM6'
width = 20
height = 4
text = []
curPos = 1
screen = driver.Driver(device_name, width, height)
screen.configSize(width, height)
screen.blinkCursor(True)
screen.clear()
def whipe():
text = []
curPos = 1;
screen.clear()
def update():
screen.clear()
screen.println(text)
screen.setCursor(curPos % 20, math.trunc(curPos))
def on_press(key):
if key == Key.space:
text.append(' ')
curPos = 1
update()
elif key == Key.backspace:
if len(text) > 0:
del text[len(text)-1]
curPos = 1
update()
elif key == Key.shift or key == Key.ctrl:
print(key)
if key == Key.esc:
else:
text.append(key.char)
curPos = 1
update()
# Collect events until released
with Listener(
on_press=on_press,
on_release=on_release) as listener:
listener.join()