Skip to content

Commit b871d1a

Browse files
committed
model provides key_name
1 parent e2baa8d commit b871d1a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

keyboard/__init__.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,11 @@
1313
from adafruit_ble.services.standard.hid import HIDService
1414

1515
from .hid import HID
16-
from .model import Matrix, COORDS, Backlight, battery_level
16+
from .model import Matrix, COORDS, Backlight, battery_level, key_name
1717
from .action_code import *
1818
from .util import usb_is_connected, do_nothing
1919

2020

21-
# fmt: off
22-
KEY_NAME = (
23-
'ESC', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 'BACKSPACE',
24-
'TAB', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', '|',
25-
'CAPS', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '"', 'ENTER',
26-
'LSHIFT', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 'RSHIFT',
27-
'LCTRL', 'LGUI', 'LALT', 'SPACE', 'RALT', 'MENU', 'FN', 'RCTRL'
28-
)
29-
# fmt: on
30-
31-
32-
def key_name(key):
33-
return KEY_NAME[COORDS[key]]
34-
35-
3621
def reset_into_bootloader():
3722
microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
3823
microcontroller.reset()
@@ -476,7 +461,8 @@ def run(self):
476461
key2 = self.get()
477462

478463
dt = ms(
479-
matrix.get_keydown_time(key2) - matrix.get_keydown_time(key1)
464+
matrix.get_keydown_time(key2)
465+
- matrix.get_keydown_time(key1)
480466
)
481467
log("pair keys {} {}, dt = {}".format(pair_index, pair, dt))
482468
try:

keyboard/model/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,17 @@
66
from .m60 import Matrix, COORDS, Backlight, battery_level
77
elif machine.find("Pitaya Go") >= 0:
88
from .pitaya_go import Matrix, COORDS, Backlight, battery_level
9+
10+
# fmt: off
11+
KEY_NAME = (
12+
'ESC', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 'BACKSPACE',
13+
'TAB', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', '|',
14+
'CAPS', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '"', 'ENTER',
15+
'LSHIFT', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 'RSHIFT',
16+
'LCTRL', 'LGUI', 'LALT', 'SPACE', 'RALT', 'MENU', 'FN', 'RCTRL'
17+
)
18+
# fmt: on
19+
20+
21+
def key_name(key):
22+
return KEY_NAME[COORDS[key]]

0 commit comments

Comments
 (0)