From b14c56f708b745e0e2e9dae0f89cce7fc43b2629 Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Thu, 11 Oct 2018 19:08:31 -0700 Subject: [PATCH] Unbreak SAMD51 by deferring imports to runtime in the entrypoint (ref #52) --- ..._m4_express.py => circuitpython_samd51.py} | 16 +++---- .../handwire/itsybitsy_m4_express.py | 43 ------------------- .../kdb424/handwire_planck_featherm4.py | 2 +- .../klardotsh/feather_m4_express/fourfour.py | 2 +- .../itsybitsy_m4_express/threethree.py | 2 +- 5 files changed, 11 insertions(+), 54 deletions(-) rename kmk/entrypoints/handwire/{feather_m4_express.py => circuitpython_samd51.py} (84%) delete mode 100644 kmk/entrypoints/handwire/itsybitsy_m4_express.py diff --git a/kmk/entrypoints/handwire/feather_m4_express.py b/kmk/entrypoints/handwire/circuitpython_samd51.py similarity index 84% rename from kmk/entrypoints/handwire/feather_m4_express.py rename to kmk/entrypoints/handwire/circuitpython_samd51.py index 52f3270..9836f43 100644 --- a/kmk/entrypoints/handwire/feather_m4_express.py +++ b/kmk/entrypoints/handwire/circuitpython_samd51.py @@ -1,13 +1,13 @@ -import sys - -from kmk.circuitpython.hid import HIDHelper -from kmk.consts import UnicodeModes -from kmk.firmware import Firmware -from kmk.matrix import MatrixScanner - - def main(): + import sys + + from kmk.circuitpython.hid import HIDHelper + from kmk.consts import UnicodeModes + from kmk.firmware import Firmware + from kmk.matrix import MatrixScanner + import kmk_keyboard_user + cols = getattr(kmk_keyboard_user, 'cols') diode_orientation = getattr(kmk_keyboard_user, 'diode_orientation') keymap = getattr(kmk_keyboard_user, 'keymap') diff --git a/kmk/entrypoints/handwire/itsybitsy_m4_express.py b/kmk/entrypoints/handwire/itsybitsy_m4_express.py deleted file mode 100644 index 52f3270..0000000 --- a/kmk/entrypoints/handwire/itsybitsy_m4_express.py +++ /dev/null @@ -1,43 +0,0 @@ -import sys - -from kmk.circuitpython.hid import HIDHelper -from kmk.consts import UnicodeModes -from kmk.firmware import Firmware -from kmk.matrix import MatrixScanner - - -def main(): - 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 - except Exception: - unicode_mode = UnicodeModes.NOOP - - try: - firmware = Firmware( - keymap=keymap, - row_pins=rows, - col_pins=cols, - diode_orientation=diode_orientation, - unicode_mode=unicode_mode, - log_level=log_level, - matrix_scanner=MatrixScanner, - hid=HIDHelper, - ) - - firmware.go() - except Exception as e: - sys.print_exception(e) - sys.exit(1) diff --git a/user_keymaps/kdb424/handwire_planck_featherm4.py b/user_keymaps/kdb424/handwire_planck_featherm4.py index d4686e0..aec444f 100644 --- a/user_keymaps/kdb424/handwire_planck_featherm4.py +++ b/user_keymaps/kdb424/handwire_planck_featherm4.py @@ -1,5 +1,5 @@ from kmk.consts import DiodeOrientation, UnicodeModes -from kmk.entrypoints.handwire.feather_m4_express import main +from kmk.entrypoints.handwire.circuitpython_samd51 import main from kmk.keycodes import KC from kmk.macros.simple import send_string from kmk.macros.unicode import unicode_string_sequence diff --git a/user_keymaps/klardotsh/feather_m4_express/fourfour.py b/user_keymaps/klardotsh/feather_m4_express/fourfour.py index 79ee33c..d52741d 100644 --- a/user_keymaps/klardotsh/feather_m4_express/fourfour.py +++ b/user_keymaps/klardotsh/feather_m4_express/fourfour.py @@ -1,5 +1,5 @@ from kmk.consts import DiodeOrientation, UnicodeModes -from kmk.entrypoints.handwire.feather_m4_express import main +from kmk.entrypoints.handwire.circuitpython_samd51 import main from kmk.firmware import Firmware from kmk.keycodes import KC from kmk.macros.simple import send_string, simple_key_sequence diff --git a/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py b/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py index 9c1a2d6..752679b 100644 --- a/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py +++ b/user_keymaps/klardotsh/itsybitsy_m4_express/threethree.py @@ -1,5 +1,5 @@ from kmk.consts import DiodeOrientation, UnicodeModes -from kmk.entrypoints.handwire.itsybitsy_m4_express import main +from kmk.entrypoints.handwire.circuitpython_samd51 import main from kmk.firmware import Firmware from kmk.keycodes import KC from kmk.macros.rotary_encoder import VolumeRotaryEncoder