Refactor MatrixScanner to use enhanced Pins abstraction; add DEBUG_ENABLED to SAMD51 boards

This commit is contained in:
Josh Klar
2018-10-11 00:29:59 -07:00
parent 70db4ae84d
commit 3b0cd6c421
10 changed files with 124 additions and 99 deletions

View File

@@ -1,14 +1,24 @@
import sys
from logging import WARNING
from kmk.circuitpython.hid import HIDHelper
from kmk.circuitpython.matrix import MatrixScanner
from kmk.common.consts import UnicodeModes
from kmk.common.matrix import MatrixScanner
from kmk.firmware import Firmware
def main():
from kmk_keyboard_user import cols, diode_orientation, keymap, rows
import kmk_keyboard_user
cols = getattr(kmk_keyboard_user, 'cols')
diode_orientation = getattr(kmk_keyboard_user, 'diode_orientation')
keymap = getattr(kmk_keyboard_user, 'keymap')
rows = getattr(kmk_keyboard_user, 'rows')
DEBUG_ENABLE = getattr(kmk_keyboard_user, 'DEBUG_ENABLE', False)
if DEBUG_ENABLE:
from logging import DEBUG as log_level
else:
from logging import ERROR as log_level
try:
from kmk_keyboard_user import unicode_mode
@@ -22,7 +32,7 @@ def main():
col_pins=cols,
diode_orientation=diode_orientation,
unicode_mode=unicode_mode,
log_level=WARNING,
log_level=log_level,
matrix_scanner=MatrixScanner,
hid=HIDHelper,
)

View File

@@ -1,14 +1,24 @@
import sys
from logging import WARNING
from kmk.circuitpython.hid import HIDHelper
from kmk.circuitpython.matrix import MatrixScanner
from kmk.common.consts import UnicodeModes
from kmk.common.matrix import MatrixScanner
from kmk.firmware import Firmware
def main():
from kmk_keyboard_user import cols, diode_orientation, keymap, rows
import kmk_keyboard_user
cols = getattr(kmk_keyboard_user, 'cols')
diode_orientation = getattr(kmk_keyboard_user, 'diode_orientation')
keymap = getattr(kmk_keyboard_user, 'keymap')
rows = getattr(kmk_keyboard_user, 'rows')
DEBUG_ENABLE = getattr(kmk_keyboard_user, 'DEBUG_ENABLE', False)
if DEBUG_ENABLE:
from logging import DEBUG as log_level
else:
from logging import ERROR as log_level
try:
from kmk_keyboard_user import unicode_mode
@@ -22,7 +32,7 @@ def main():
col_pins=cols,
diode_orientation=diode_orientation,
unicode_mode=unicode_mode,
log_level=WARNING,
log_level=log_level,
matrix_scanner=MatrixScanner,
hid=HIDHelper,
)

View File

@@ -2,8 +2,8 @@ import sys
import gc
from kmk.common.matrix import MatrixScanner
from kmk.firmware import Firmware
from kmk.micropython.matrix import MatrixScanner
from kmk.micropython.pyb_hid import HIDHelper
@@ -17,9 +17,9 @@ def main():
DEBUG_ENABLE = getattr(kmk_keyboard_user, 'DEBUG_ENABLE', False)
if DEBUG_ENABLE:
from logging import DEBUG
from logging import DEBUG as log_level
else:
from logging import ERROR as DEBUG
from logging import ERROR as log_level
# This will run out of ram at this point unless you manually GC
gc.collect()
@@ -31,7 +31,7 @@ def main():
col_pins=cols,
diode_orientation=diode_orientation,
hid=HIDHelper,
log_level=DEBUG,
log_level=log_level,
matrix_scanner=MatrixScanner,
)
# This will run out of ram at this point unless you manually GC