boot.py
 1  # SPDX-FileCopyrightText: 2022 Tod Kurt & John Park for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  #
 5  # boot.py to enable or disable usb_hid
 6  import usb_hid
 7  import board
 8  import digitalio
 9  
10  # set a pull-up
11  # If not pressed, the key will be at +V (due to the pull-up)
12  button = digitalio.DigitalInOut(board.D2)
13  button.pull = digitalio.Pull.UP
14  
15  # Disable devices only if button is not pressed
16  # Phone receiver is normally open when handset is in place
17  if button.value:
18      print("USB HID disabled")
19      usb_hid.disable()