diff --git a/rotary-kb.py b/rotary-kb.py index 0ae03f0..a5bd91f 100755 --- a/rotary-kb.py +++ b/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":