Add support for a Planck Rev 6 spidered to a Feather M4 Express

This commit is contained in:
Josh Klar 2018-10-16 01:04:36 -07:00
parent 10ca6816a2
commit 0c72554773
No known key found for this signature in database
GPG Key ID: 220F99BD7DB7A99E
2 changed files with 67 additions and 3 deletions
kmk
user_keymaps/klardotsh/feather_m4_express

View File

@ -16,6 +16,9 @@ class MatrixScanner:
self.cols = cols
self.rows = rows
self.len_cols = len(cols)
self.len_rows = len(rows)
self.diode_orientation = diode_orientation
self.last_pressed_len = 0
@ -36,6 +39,18 @@ class MatrixScanner:
for pin in self.inputs:
pin.switch_to_input(pull=digitalio.Pull.DOWN)
import kmk_keyboard
self.swap_indicies = getattr(kmk_keyboard, 'swap_indicies', {})
self.rollover_cols_every_rows = getattr(
kmk_keyboard,
'rollover_cols_every_rows',
self.len_rows,
)
for k, v in self.swap_indicies.items():
self.swap_indicies[v] = k
def scan_for_pressed(self):
pressed = []
@ -44,9 +59,19 @@ class MatrixScanner:
for iidx, ipin in enumerate(self.inputs):
if ipin.value():
pressed.append(
(oidx, iidx) if self.diode_orientation == DiodeOrientation.ROWS else (iidx, oidx) # noqa
)
if self.diode_orientation == DiodeOrientation.ROWS:
report_tuple = (oidx, iidx)
else:
new_oidx = oidx + self.len_cols * (iidx // self.rollover_cols_every_rows)
new_iidx = iidx - self.rollover_cols_every_rows * (
iidx // self.rollover_cols_every_rows
)
report_tuple = (new_iidx, new_oidx)
if report_tuple in self.swap_indicies:
report_tuple = self.swap_indicies[report_tuple]
pressed.append(report_tuple)
opin.value(False)

View File

@ -0,0 +1,39 @@
from kmk.consts import DiodeOrientation, UnicodeModes
from kmk.entrypoints.handwire.circuitpython_samd51 import main
from kmk.keycodes import KC
from kmk.macros.simple import send_string
from kmk.macros.unicode import unicode_string_sequence
from kmk.pins import Pin as P
from kmk.types import AttrDict
# physical, visible cols (SCK, MO, MI, RX, TX, D4)
# physical, visible rows (10, 11, 12, 13) (9, 6, 5, SCL)
cols = (P.SCK, P.MOSI, P.MISO, P.RX, P.TX, P.D4)
rows = (P.D10, P.D11, P.D12, P.D13, P.D9, P.D6, P.D5, P.SCL)
swap_indicies = {
(3, 3): (3, 9),
(3, 4): (3, 10),
(3, 5): (3, 11),
}
rollover_cols_every_rows = 4
diode_orientation = DiodeOrientation.COLUMNS
# ------------------User level config variables ---------------------------------------
unicode_mode = UnicodeModes.LINUX
debug_enable = True
keymap = [
[
[KC.A, KC.E, KC.I, KC.M, KC.Q, KC.U, KC.N1, KC.N5, KC.N9, KC.HASH, KC.AMPR, KC.UNDS],
[KC.B, KC.F, KC.J, KC.N, KC.R, KC.V, KC.N2, KC.N6, KC.N0, KC.DOLLAR, KC.ASTR, KC.LCBR],
[KC.C, KC.G, KC.K, KC.O, KC.S, KC.W, KC.N3, KC.N7, KC.EXCLAIM, KC.PERCENT, KC.LPRN, KC.RCBR],
[KC.D, KC.H, KC.L, KC.P, KC.T, KC.X, KC.N4, KC.N8, KC.AT, KC.CIRC, KC.RPRN, KC.PIPE],
],
]
if __name__ == '__main__':
main()