cleanup, add backspace

This commit is contained in:
Crispy 2022-05-16 17:29:09 +02:00
parent 73ca03e981
commit ccbced419d

View file

@ -1,12 +1,13 @@
#!/bin/env python3
import serial
import time
import os
from pynput import mouse, keyboard
PORT = "/dev/ttyACM1"
keys = list(" abcdefghijklmnopqrstuvwxyz") + [keyboard.Key.enter]
keys_display = " abcdefghijklmnopqrstuvwxyz\\"
keys = list(" abcdefghijklmnopqrstuvwxyz") + [keyboard.Key.enter, keyboard.Key.backspace]
keys_display = " abcdefghijklmnopqrstuvwxyz\\<"
kb = keyboard.Controller()
arduino = serial.Serial(port=PORT, baudrate=9600, timeout=.1)
@ -15,12 +16,23 @@ active_btn = -1
pos = 0
if os.name == "nt":
def clear():
os.system("cls")
else:
def clear():
os.system("clear")
def print_state():
global pos
clear()
print(keys_display)
print(" " * pos + "^")
print(pos)
print_state()
while True:
event = arduino.readline().decode("utf-8").replace("\r\n", "")
if event == "cw":