From ffab7332f62ffdc1971631a7f66f1a44bbbe90d5 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Wed, 19 Apr 2023 10:00:27 -0400 Subject: [PATCH] cleanup boot.py, move imports to where they are used to help with faster startup times in debug mode ; general code cleanup ; this should be the 'final form' for now --- boot.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/boot.py b/boot.py index a19097f..5863267 100644 --- a/boot.py +++ b/boot.py @@ -1,17 +1,17 @@ print('START boot.py') -# Used http://kmkfw.io/docs/boot/ as starting point +# Used http://kmkfw.ioy/docs/boot/ as starting point -import supervisor -import board -import digitalio import os -import storage -import usb_cdc -import usb_hid -from kmk.quickpin.pro_micro.kb2040 import pinout as pins +# Enable use w/ BIOS +if os.getenv('ARDUX_KMK_DEBUGGING'): + print('START bios hid enable') +import usb_hid from usb_hid import Device +usb_hid.enable((Device.KEYBOARD, Device.MOUSE), boot_device=1) +if os.getenv('ARDUX_KMK_DEBUGGING'): + print('END bios hid enable') # Print env vars if debugging enabled if os.getenv('ARDUX_KMK_DEBUGGING'): @@ -29,6 +29,8 @@ else: # If this key is held during boot, don't run the code which hides the storage and disables serial # bottom row, index finger key / bottom row pinky key +import digitalio +from kmk.quickpin.pro_micro.kb2040 import pinout as pins key_1 = digitalio.DigitalInOut(pins[12]) key_2 = digitalio.DigitalInOut(pins[15]) @@ -43,15 +45,13 @@ key_2_val = not (key_2.value) # Check for key hold and disable any dangerous features if not (key_1_val or key_2_val) and not os.getenv('ARDUX_KMK_DEBUGGING'): if not os.getenv('ARDUX_KMK_USB_DISK_ALWAYS'): + import storage storage.disable_usb_drive() + import usb_cdc usb_cdc.disable() # Equivalent to usb_cdc.enable(console=False, data=False) # Deinit pins so they can be setup per the kmk keymap post-boot key_1.deinit() key_2.deinit() -# Enable use w/ BIOS - -usb_hid.enable(boot_device=1) - print('END boot.py')