Refs #104: Keyboard can work without REPL connected on >=4.0.0-alpha3 (tested only against single-piece boards so far)

This commit is contained in:
Josh Klar 2019-05-12 14:13:41 -07:00
parent cf5ee5d4b2
commit 7fcd36f2fb

View File

@ -139,7 +139,14 @@ class Firmware:
if self.is_master is not None:
return self.is_master
return supervisor.runtime.serial_connected
# Working around https://github.com/adafruit/circuitpython/issues/1769
try:
self._hid_helper_inst.create_report([]).send()
self.is_master = True
except OSError:
self.is_master = False
return self.is_master
def init_uart(self, pin, timeout=20):
if self._master_half():
@ -153,6 +160,8 @@ 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'
self._hid_helper_inst = self.hid_helper()
# Split keyboard Init
if self.split_flip and not self._master_half():
self.col_pins = list(reversed(self.col_pins))
@ -173,8 +182,6 @@ class Firmware:
swap_indicies=getattr(self, 'swap_indicies', None),
)
self._hid_helper_inst = self.hid_helper()
# Compile string leader sequences
for k, v in self.leader_dictionary.items():
if not isinstance(k, tuple):