cleanup, add backspace
This commit is contained in:
parent
73ca03e981
commit
ccbced419d
1 changed files with 14 additions and 2 deletions
16
rotary-kb.py
16
rotary-kb.py
|
@ -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":
|
||||
|
|
Loading…
Reference in a new issue