diff --git a/kmk/firmware.py b/kmk/firmware.py index 363f46a..7c3f003 100644 --- a/kmk/firmware.py +++ b/kmk/firmware.py @@ -65,6 +65,7 @@ class Firmware: split_type = None split_offsets = () split_master_left = True + uart = None def __init__(self): self._state = InternalState(self) @@ -83,8 +84,8 @@ class Firmware: self._send_hid() def _handle_update(self, update): - if self.split_type is not None and not self.split_master_left: - update[1] += self.split_offsets[update[1]] + # if self.split_type is not None and not self.split_master_left: + # update[1] += self.split_offsets[update[1]] if update is not None: self._state.matrix_changed( @@ -112,20 +113,20 @@ class Firmware: def _send_to_master(self, update): if self.split_type == "UART": if self.uart is None: - self.uart = busio.UART(board.TX, board.RX, timeout=0) + self.uart = busio.UART(board.TX, board.RX, timeout=1) # Update column with offset - if self.split_master_left: - update[1] += self.split_offsets[update[1]] + # if self.split_master_left: + # update[1] += self.split_offsets[update[1]] self.uart.write(update) def _receive_from_slave(self): if self.split_type == "UART": if self.uart is None: - self.uart = busio.UART(board.TX, board.RX, timeout=0) + self.uart = busio.UART(board.TX, board.RX, timeout=1) - update = self.uart.read() + update = self.uart.read(nbytes=3) return update return None @@ -150,18 +151,21 @@ class Firmware: print("Firin' lazers. Keyboard is booted.") while True: - if self.split_type is not None: + if self.split_type is not None and supervisor.runtime.serial_connected: update = self._receive_from_slave() + print(str(update)) if update is not None: self._handle_update(update) for update in self.matrix.scan_for_changes(): - # Abstract this later. Bluetooth will fail here - if supervisor.runtime.serial_connected: - self._handle_update(update) + if update is not None: + # Abstract this later. Bluetooth will fail here + if supervisor.runtime.serial_connected: + if update is not None: + self._handle_update(update) - else: - # This keyboard is a slave, and needs to send data to master - self._send_to_master(update) + else: + # This keyboard is a slave, and needs to send data to master + self._send_to_master(update) gc.collect() diff --git a/user_keymaps/kdb424/levinson_m4.py b/user_keymaps/kdb424/levinson_m4.py index 8d3c9f4..3084822 100644 --- a/user_keymaps/kdb424/levinson_m4.py +++ b/user_keymaps/kdb424/levinson_m4.py @@ -9,8 +9,8 @@ from kmk.types import AttrDict keyboard = Firmware() -keyboard.col_pins = (P.A0, P.A1, P.A2, P.A3, P.A4, P.A5, P.SCK, P.MOSI, P.MISO, P.RX, P.TX, P.D4) -keyboard.row_pins = (P.D10, P.D11, P.D12, P.D13) +keyboard.col_pins = (P.D10, P.D9, P.D7, P.D5, P.A4, P.A5) +keyboard.row_pins = (P.A0, P.A1, P.A2, P.A3) keyboard.diode_orientation = DiodeOrientation.COLUMNS @@ -19,6 +19,8 @@ keyboard.unicode_mode = UnicodeModes.LINUX keyboard.tap_time = 900 keyboard.leader_timeout = 2000 keyboard.debug_enabled = True +keyboard.split_type = "UART" +keyboard.split_offsets = [5, 5, 5, 5] emoticons = compile_unicode_string_sequences({ # Emoticons, but fancier