refactor debugging code so its better organized and adjust the output to be more meaningful

This commit is contained in:
KemoNine 2023-04-19 08:43:39 -04:00
parent f14f4bcb41
commit bba59ca7ab
2 changed files with 16 additions and 15 deletions

29
boot.py
View file

@ -1,7 +1,6 @@
print('START boot.py') print('START boot.py')
# http://kmkfw.io/docs/boot/ # Used http://kmkfw.io/docs/boot/ as starting point
# Below is a fully working example, which disables USB storage, CDC and enables BIOS mode.
import supervisor import supervisor
import board import board
@ -15,6 +14,20 @@ from kmk.quickpin.pro_micro.kb2040 import pinout as pins
from kb import KMKKeyboard from kb import KMKKeyboard
from usb_hid import Device from usb_hid import Device
# Print env vars if debugging enabled
if os.getenv('ARDUX_KMK_DEBUGGING'):
print('debugging enabled')
print('START env')
print('CIRCUITPY_BLE_NAME:', os.getenv('CIRCUITPY_BLE_NAME'))
print('ARDUX_KMK_DEBUGGING:', os.getenv('ARDUX_KMK_DEBUGGING'))
print('ARDUX_KMK_USB_DISK_ALWAYS:', os.getenv('ARDUX_KMK_USB_DISK_ALWAYS'))
print('ARDUX_SIZE:', os.getenv('ARDUX_SIZE'))
print('ARDUX_HAND:', os.getenv('ARDUX_HAND'))
print('ARDUX_BOARD:', os.getenv('ARDUX_BOARD'))
print('END env')
else:
print('debugging disabled')
# Enable use w/ BIOS # Enable use w/ BIOS
usb_hid.enable((Device.KEYBOARD, Device.MOUSE), boot_device=1) usb_hid.enable((Device.KEYBOARD, Device.MOUSE), boot_device=1)
@ -30,7 +43,7 @@ key_2.switch_to_input(pull=digitalio.Pull.UP)
key_1_val = not (key_1.value) key_1_val = not (key_1.value)
key_2_val = not (key_2.value) key_2_val = not (key_2.value)
if not (key_1_val or key_2_val): 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'): if not os.getenv('ARDUX_KMK_USB_DISK_ALWAYS'):
storage.disable_usb_drive() storage.disable_usb_drive()
usb_cdc.disable() # Equivalent to usb_cdc.enable(console=False, data=False) usb_cdc.disable() # Equivalent to usb_cdc.enable(console=False, data=False)
@ -39,14 +52,4 @@ if not (key_1_val or key_2_val):
key_1.deinit() key_1.deinit()
key_2.deinit() key_2.deinit()
if os.getenv('ARDUX_KMK_DEBUGGING'):
print('START env')
print('CIRCUITPY_BLE_NAME:', os.getenv('CIRCUITPY_BLE_NAME'))
print('ARDUX_KMK_DEBUGGING:', os.getenv('ARDUX_KMK_DEBUGGING'))
print('ARDUX_KMK_USB_DISK_ALWAYS:', os.getenv('ARDUX_KMK_USB_DISK_ALWAYS'))
print('ARDUX_SIZE:', os.getenv('ARDUX_SIZE'))
print('ARDUX_HAND:', os.getenv('ARDUX_HAND'))
print('ARDUX_BOARD:', os.getenv('ARDUX_BOARD'))
print('END env')
print('END boot.py') print('END boot.py')

View file

@ -74,7 +74,5 @@ keyboard.keymap = [
##### #####
# Main # Main
if __name__ == '__main__': if __name__ == '__main__':
print('begin main.py')
keyboard.go() keyboard.go()
print('end main.py')