Merge pull request #127 from KMKfw/topic-cpy4-rc2-compat

Compatibility with CircuitPython 4.0.0-rc2
This commit is contained in:
Josh Klar 2019-05-12 16:08:51 -07:00 committed by GitHub
commit d70c2ccc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 4 deletions

4
.gitignore vendored
View File

@ -115,3 +115,7 @@ venv.bak/
# Personal dev scripts
.scripts
# Mountpoints
mnt/
mnt2/

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):

View File

@ -73,8 +73,19 @@ class MatrixScanner:
opin.value(True)
for iidx, ipin in enumerate(self.inputs):
# cast to int to avoid
#
# >>> xyz = bytearray(3)
# >>> xyz[2] = True
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# OverflowError: value would overflow a 1 byte buffer
#
# I haven't dived too far into what causes this, but it's
# almost certainly because bool types in Python aren't just
# aliases to int values, but are proper pseudo-types
new_val = int(ipin.value())
old_val = self.state[ba_idx]
new_val = ipin.value()
if old_val != new_val:
if self.translate_coords:
@ -97,6 +108,7 @@ class MatrixScanner:
self.report[2] = new_val
self.state[ba_idx] = new_val
any_changed = True
break