Skip to content

Commit e3bce0a

Browse files
committed
more small fixes
1 parent 69caf90 commit e3bce0a

File tree

1 file changed

+12
-5
lines changed
  • CircuitPython_Tandy1000Keyboard_QTPy_RP2040

1 file changed

+12
-5
lines changed

CircuitPython_Tandy1000Keyboard_QTPy_RP2040/code.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
from adafruit_hid.keyboard import Keyboard
1111
from adafruit_hid.keycode import Keycode as K
1212

13+
KBD_NRESET = board.MISO
14+
KBD_DATA = board.RX
15+
KBD_CLOCK = board.SCK # Note that KBD_CLOCK must be 1 GPIO# above KBD_DATA
16+
KBD_NBUSY = board.MOSI
17+
1318
tandy1000_keycodes = [
1419
None, K.ESCAPE, K.ONE, K.TWO, K.THREE, K.FOUR, K.FIVE, K.SIX, K.SEVEN,
1520
K.EIGHT, K.NINE, K.ZERO, K.MINUS, K.EQUALS, K.BACKSPACE, K.TAB, K.Q, K.W,
@@ -71,11 +76,6 @@
7176
}
7277
]
7378

74-
KBD_NRESET = board.MISO
75-
KBD_DATA = board.RX
76-
KBD_CLOCK = board.SCK # Note that KBD_CLOCK must be 1 GPIO above KBD_DATA
77-
KBD_NBUSY = board.MOSI
78-
7979
# Assert busy
8080
busy_out = digitalio.DigitalInOut(KBD_NBUSY)
8181
busy_out.switch_to_output(False, digitalio.DriveMode.OPEN_DRAIN)
@@ -117,6 +117,13 @@
117117
pressed = (val & 0x80) == 0
118118
key_number = val & 0x7f
119119

120+
if key_number > len(tandy1000_keycodes):
121+
# invalid keycode -- reset the keyboard
122+
reset_out.switch_to_output(False, digitalio.DriveMode.OPEN_DRAIN)
123+
time.sleep(.1)
124+
reset_out.value = True
125+
continue
126+
120127
keycode = tandy1000_keycodes[key_number]
121128
if keycode is None:
122129
continue

0 commit comments

Comments
 (0)