Very broken, but some work done probably

This commit is contained in:
Kyle Brown
2018-09-21 17:22:03 -07:00
committed by Josh Klar
parent d0f35100b3
commit 7ae2d18e45
9 changed files with 63 additions and 13 deletions

View File

@@ -2,7 +2,7 @@ from kmk.common.consts import DiodeOrientation
class AbstractMatrixScanner():
def __init__(self, cols, rows, diode_orientation=DiodeOrientation.COLUMNS):
def __init__(self, cols, rows, active_layers, diode_orientation=DiodeOrientation.COLUMNS):
raise NotImplementedError('Abstract implementation')
def _normalize_matrix(self, matrix):

View File

@@ -5,29 +5,32 @@ KEY_DOWN_EVENT = const(2)
INIT_FIRMWARE_EVENT = const(3)
def init_firmware(keymap, row_pins, col_pins, diode_orientation):
def init_firmware(keymap, row_pins, col_pins, diode_orientation, active_layers):
return {
'type': INIT_FIRMWARE_EVENT,
'keymap': keymap,
'row_pins': row_pins,
'col_pins': col_pins,
'diode_orientation': diode_orientation,
'active_layers': active_layers,
}
def key_up_event(keycode, row, col):
def key_up_event(keycode, row, col, active_layers):
return {
'type': KEY_UP_EVENT,
'keycode': keycode,
'row': row,
'col': col,
'active_layers': active_layers,
}
def key_down_event(keycode, row, col):
def key_down_event(keycode, row, col, active_layers):
return {
'type': KEY_DOWN_EVENT,
'keycode': keycode,
'row': row,
'col': col,
'active_layers': active_layers,
}

View File

@@ -1,7 +1,9 @@
def process(self, state, key):
self.logger.warning(key)
if key.code == 1000:
def process(self, state, action):
self.logger.warning(action['keycode'])
if action['keycode'].code == 1000:
reset(self)
elif action['keycode'].code == 1050:
df(self, "Filler", action)
def reset(self):
@@ -9,3 +11,32 @@ def reset(self):
import machine
machine.bootloader()
return self
def df(self, layer, action):
"""Switches the default layer"""
self.logger.warning(action['active_layers'])
def mo(layer):
"""Momentarily activates layer, switches off when you let go"""
def lm(layer, mod):
"""As MO(layer) but with mod active"""
def lt(layer, kc):
"""Momentarily activates layer if held, sends kc if tapped"""
def tg(layer):
"""Toggles the layer (enables it if no active, and vise versa)"""
def to(layer):
"""Activates layer and deactivates all other layers"""
def tt(layer):
"""Momentarily activates layer if held, toggles it if tapped repeatedly"""

View File

@@ -48,6 +48,7 @@ class InternalState:
col_pins = []
matrix = []
diode_orientation = DiodeOrientation.COLUMNS
active_layers = [0]
@property
def __dict__(self):
@@ -58,6 +59,7 @@ class InternalState:
'col_pins': self.col_pins,
'row_pins': self.row_pins,
'diode_orientation': self.diode_orientation,
'active_layers': self.active_layers,
}
def __repr__(self):
@@ -124,6 +126,7 @@ def kmk_reducer(state=None, action=None, logger=None):
row_pins=action['row_pins'],
col_pins=action['col_pins'],
diode_orientation=action['diode_orientation'],
active_layers=action['active_layers'],
matrix=[
[False for c in action['col_pins']]
for r in action['row_pins']

View File

@@ -321,6 +321,15 @@ class Keycodes(KeycodeCategory):
KC_LEAD = Keycode(1005, False)
KC_LOCK = Keycode(1006, False)
class Layers(KeycodeCategory):
KC_DF = Keycode(1050, False)
KC_MO = Keycode(1051, False)
KC_LM = Keycode(1052, False)
KC_LT = Keycode(1053, False)
KC_TG = Keycode(1054, False)
KC_TO = Keycode(1055, False)
KC_TT = Keycode(1056, False)
ALL_KEYS = KC = AttrDict({
k.replace('KC_', ''): v