Fully working split. Needs further testing

This commit is contained in:
Kyle Brown 2018-10-19 12:17:47 -07:00
parent af3eccd715
commit 8d3e4e0a63
2 changed files with 15 additions and 9 deletions

View File

@ -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,7 +125,10 @@ class Firmware:
if self.uart is None:
self.uart = busio.UART(board.TX, board.RX, timeout=1)
update = self.uart.read(nbytes=3)
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,15 +158,15 @@ 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:
print(str(update))
self._handle_update(update)
else:

View File

@ -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