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