diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2023-05-22 08:40:47 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2023-05-22 08:40:47 +0200 |
commit | 597b007333d8ec0d9cfd29e6941fcbe57379108a (patch) | |
tree | 0cf87e1ac487e7deb91acf7f2bec70bd4dd06703 /src/boot.py |
Initial commit
Diffstat (limited to 'src/boot.py')
-rw-r--r-- | src/boot.py | 20 |
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") |