From 597b007333d8ec0d9cfd29e6941fcbe57379108a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 22 May 2023 08:40:47 +0200 Subject: Initial commit --- src/boot.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/boot.py (limited to 'src/boot.py') 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") -- cgit v1.2.3