summaryrefslogtreecommitdiff
path: root/src/boot.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot.py')
-rw-r--r--src/boot.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/boot.py b/src/boot.py
new file mode 100644
index 0000000..0a30e17
--- /dev/null
+++ b/src/boot.py
@@ -0,0 +1,20 @@
+# This example is for the MacroPad,
+# or any board with buttons that are connected to ground when pressed.
+
+import usb_cdc
+import storage
+import board, digitalio
+
+# On the Macropad, pressing a key grounds it. You need to set a pull-up.
+# If not pressed, the key will be at +V (due to the pull-up).
+# The KEY12 is the RightBotom key in the keypad
+button = digitalio.DigitalInOut(board.KEY12)
+button.pull = digitalio.Pull.UP
+
+usb_cdc.enable(console=True, data=True)
+# Disable devices only if button is not pressed.
+if button.value:
+ print("KEY12 Unpressed, starting without storage")
+ storage.disable_usb_drive()
+else:
+ print("Mounting USB storage")