Skip to content

Commit 9376ad7

Browse files
committed
compatible with hand-wired keyboard
1 parent 017426a commit 9376ad7

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

keyboard/__init__.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
# fmt: off
2121
KEY_NAME = (
2222
'ESC', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 'BACKSPACE',
23-
'|', ']', '[', 'P', 'O', 'I', 'U', 'Y', 'T', 'R', 'E', 'W', 'Q', 'TAB', 'CAPS',
23+
'CAPS', 'TAB', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', '|',
2424
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '"', 'ENTER',
25-
'RSHIFT', '/', '.', ',', 'M', 'N', 'B', 'V', 'C', 'X', 'Z', 'LSHIFT',
25+
'LSHIFT', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 'RSHIFT',
2626
'LCTRL', 'LGUI', 'LALT', 'SPACE', 'RALT', 'MENU', 'FN', 'RCTRL'
2727
)
2828
# fmt: on
2929

3030

31+
def key_name(key):
32+
return KEY_NAME[COORDS[key]]
33+
34+
3135
@micropython.asm_thumb
3236
def mem(r0):
3337
"""Read memory from the address"""
@@ -105,11 +109,12 @@ def __init__(self, keymap=(), pairs=(), verbose=True):
105109
self._connection = ""
106110
self.adv_timeout = None
107111

108-
self.data = array.array("L", microcontroller.nvm[:272])
112+
size = 4 + self.matrix.keys
113+
self.data = array.array("L", microcontroller.nvm[:size*4])
109114
if self.data[0] != 0x424B5950:
110115
self.data[0] = 0x424B5950
111116
self.data[1] = 1
112-
for i in range(4, 68):
117+
for i in range(4, size):
113118
self.data[i] = 0
114119
self.ble_id = self.data[1]
115120
self.heatmap = memoryview(self.data)[4:]
@@ -211,7 +216,7 @@ def get_key_sequence_info(self, start, end):
211216
matrix = self.matrix
212217
event = matrix.view(start - 1)
213218
key = event & 0x7F
214-
desc = KEY_NAME[key]
219+
desc = key_name(key)
215220
if event < 0x80:
216221
desc += " \\ "
217222
t0 = matrix.get_keydown_time(key)
@@ -223,7 +228,7 @@ def get_key_sequence_info(self, start, end):
223228
for i in range(start, end):
224229
event = matrix.view(i)
225230
key = event & 0x7F
226-
desc += KEY_NAME[key]
231+
desc += key_name(key)
227232
if event < 0x80:
228233
desc += " \\ "
229234
t1 = matrix.get_keydown_time(key)
@@ -570,7 +575,7 @@ def run(self):
570575
last_time = keydown_time
571576
print(
572577
"{} {} \\ {} latency {} | {}".format(
573-
key, KEY_NAME[key], hex(action_code), dt, dt2
578+
key, key_name(key), hex(action_code), dt, dt2
574579
)
575580
)
576581
else:
@@ -619,6 +624,6 @@ def run(self):
619624
last_time = keyup_time
620625
print(
621626
"{} {} / {} latency {} | {}".format(
622-
key, KEY_NAME[key], hex(action_code), dt, dt2
627+
key, key_name(key), hex(action_code), dt, dt2
623628
)
624629
)

keyboard/model/pitaya_go.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# fmt: off
22

3-
from ..matrix import Matrix
43
from board import P27, P13, P30, P20, P3, P26, P31, P29, P28, P5, P4, P24, P25, P23, P22, P14, P15, P16, P17
5-
from backlight import Backlight
4+
from .backlight import Backlight
5+
from ..matrix import Matrix
66

77
Matrix.ROWS = (P27, P13, P30, P20, P3)
88
Matrix.COLS = (P26, P31, P29, P28, P5, P4, P24, P25, P23, P22, P14, P15, P16, P17)

0 commit comments

Comments
 (0)