From ccbced419d3d77757935149abf8ebe94e85c5390 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Mon, 16 May 2022 17:29:09 +0200 Subject: [PATCH] cleanup, add backspace --- rotary-kb.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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":