First keys on slave half actually type! Still needs a bit of work
This commit is contained in:
parent
49da93e436
commit
af3eccd715
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user