diff --git a/kmk/firmware.py b/kmk/firmware.py index 7c3f003..5c2387b 100644 --- a/kmk/firmware.py +++ b/kmk/firmware.py @@ -64,6 +64,7 @@ class Firmware: split_type = None split_offsets = () + split_flip = True split_master_left = True uart = None @@ -86,6 +87,7 @@ class Firmware: 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]] + print(update[1]) if update is not None: self._state.matrix_changed( @@ -115,9 +117,6 @@ class Firmware: if self.uart is None: 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]] self.uart.write(update) @@ -126,8 +125,11 @@ class Firmware: if self.uart is None: self.uart = busio.UART(board.TX, board.RX, timeout=1) - update = self.uart.read(nbytes=3) - return update + if self.uart.in_waiting > 0: + update = bytearray(self.uart.read()) + if self.split_master_left: + update[1] += self.split_offsets[update[0]] + return update return None @@ -137,6 +139,9 @@ class Firmware: assert self.col_pins, 'no GPIO pins defined for matrix columns' assert self.diode_orientation is not None, 'diode orientation must be defined' + if self.split_flip and not supervisor.runtime.serial_connected: + self.col_pins = list(reversed(self.col_pins)) + self.matrix = MatrixScanner( cols=self.col_pins, rows=self.row_pins, @@ -153,16 +158,16 @@ class Firmware: while True: 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: + print(str(update)) self._handle_update(update) for update in self.matrix.scan_for_changes(): 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) + print(str(update)) + self._handle_update(update) else: # This keyboard is a slave, and needs to send data to master diff --git a/user_keymaps/kdb424/levinson_m4.py b/user_keymaps/kdb424/levinson_m4.py index 3084822..661d530 100644 --- a/user_keymaps/kdb424/levinson_m4.py +++ b/user_keymaps/kdb424/levinson_m4.py @@ -20,7 +20,8 @@ keyboard.tap_time = 900 keyboard.leader_timeout = 2000 keyboard.debug_enabled = True keyboard.split_type = "UART" -keyboard.split_offsets = [5, 5, 5, 5] +keyboard.split_flip = True +keyboard.split_offsets = [6, 6, 6, 6] emoticons = compile_unicode_string_sequences({ # Emoticons, but fancier