This post is related to the project Mouse Jiggler Pico.

Disable Storage on a Raspberry Pi Pico

2023-12-03 · christian · embedded, projects, projects:mouse-jiggler, python

When using a Raspberry Pi Pico as a USB Mouse or Keyboard, you may want to disable CircuitPythons flash drive and the REPL serial console.

Just put the following into the boot.py:

import storage
import usb_cdc
import usb_midi

storage.disable_usb_drive()
usb_cdc.disable()
usb_midi.disable()

The actual logic of your program should be put into the code.py and will be launched after boot.py has completed.

It is also possible to add a physical button to skip disabling the Flash Drive. The following example will not disable it, when the button is hold while resetting the Pico:

import board
import storage
import usb_cdc
import usb_midi
from digitalio import DigitalInOut, Direction, Pull

btn = DigitalInOut(board.GP13)
btn.direction = Direction.INPUT
btn.pull = Pull.DOWN

if not btn.value:
    storage.disable_usb_drive()
    usb_cdc.disable()
    usb_midi.disable()

Pico Jiggler


More


serverless.industries BG by Carl Lender (CC BY 2.0) Imprint & Privacy
4fa348d0 2024-08-31 14:04
Mastodon via chaos.social Mastodon via einbeck.social