2019-07-25 09:32:20 +02:00
|
|
|
import board
|
|
|
|
|
2019-07-25 10:30:55 +02:00
|
|
|
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
|
Continue to shuffle and burn stuff
- Remove the concept of "mcus". With only one target platform
(CircuitPython), it no longer makes a bunch of sense and has been kept
around for "what if" reasons, complicating our import chains and eating
up RAM for pointless subclasses. If you're a `board`, you derive from
`KeyboardConfig`. If you're a handwire, the user will derive from
`KeyboardConfig`. The end. As part of this, `kmk.hid` was refactored
heavily to emphasize that CircuitPython is our only supported HID stack,
with stubs for future HID implementations (`USB_HID` becomes
`AbstractHID`, probably only usable for testing purposes,
`CircuitPython_USB_HID` becomes `USBHID`, and `BLEHID` is added with an
immediate `NotImplementedError` on instantiation)
- `KeyboardConfig` can now take a HID type at runtime. The NRF52840
boards will happily run in either configuration once CircuitPython
support is in place, and a completely separate `mcu` subclass for each
mode made no sense. This also potentially allows runtime *swaps* of HID
driver down the line, but no code has been added to this effect. The
default, and only functional value, for this is `HIDModes.USB`
- Most consts have been moved to more logical homes - often, the main
or, often only, component that uses them. `DiodeOrientation` moved to
`kmk.matrix`, and anything HID-related moved to `kmk.hid`
2019-07-25 09:58:23 +02:00
|
|
|
from kmk.matrix import DiodeOrientation
|
2019-07-25 08:43:00 +02:00
|
|
|
from kmk.matrix import intify_coordinate as ic
|
2020-10-21 21:19:42 +02:00
|
|
|
from kmk.modules.layers import Layers
|
2019-05-13 02:04:23 +02:00
|
|
|
|
2019-07-25 10:30:55 +02:00
|
|
|
# Implements what used to be handled by KMKKeyboard.swap_indicies for this
|
2019-05-13 02:04:23 +02:00
|
|
|
# board, by flipping various row3 (bottom physical row) keys so their
|
|
|
|
# coord_mapping matches what the user pressed (even if the wiring
|
|
|
|
# underneath is sending different coordinates)
|
2019-07-25 07:57:11 +02:00
|
|
|
_r3_swap_conversions = {3: 9, 4: 10, 5: 11, 9: 3, 10: 4, 11: 5}
|
2019-05-13 02:04:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
def r3_swap(col):
|
|
|
|
try:
|
|
|
|
return _r3_swap_conversions[col]
|
|
|
|
except KeyError:
|
|
|
|
return col
|
2018-10-16 13:04:39 +02:00
|
|
|
|
|
|
|
|
2019-07-25 10:30:55 +02:00
|
|
|
class KMKKeyboard(_KMKKeyboard):
|
2018-10-16 13:04:39 +02:00
|
|
|
# physical, visible cols (SCK, MO, MI, RX, TX, D4)
|
|
|
|
# physical, visible rows (10, 11, 12, 13) (9, 6, 5, SCL)
|
2019-07-25 09:32:20 +02:00
|
|
|
col_pins = (board.SCK, board.MOSI, board.MISO, board.RX, board.TX, board.D4)
|
|
|
|
row_pins = (
|
|
|
|
board.D10,
|
|
|
|
board.D11,
|
|
|
|
board.D12,
|
|
|
|
board.D13,
|
|
|
|
board.D9,
|
|
|
|
board.D6,
|
|
|
|
board.D5,
|
|
|
|
board.SCL,
|
|
|
|
)
|
2018-10-16 13:04:39 +02:00
|
|
|
rollover_cols_every_rows = 4
|
|
|
|
diode_orientation = DiodeOrientation.COLUMNS
|
|
|
|
|
2019-05-13 02:04:23 +02:00
|
|
|
coord_mapping = []
|
|
|
|
coord_mapping.extend(ic(0, x) for x in range(12))
|
|
|
|
coord_mapping.extend(ic(1, x) for x in range(12))
|
|
|
|
coord_mapping.extend(ic(2, x) for x in range(12))
|
|
|
|
coord_mapping.extend(ic(3, r3_swap(x)) for x in range(12))
|
2020-10-21 21:19:42 +02:00
|
|
|
|
|
|
|
layers_ext = Layers()
|
|
|
|
modules = [layers_ext]
|