Skip to content

Instantly share code, notes, and snippets.

@vitorio
Last active July 20, 2023 03:20
Show Gist options
  • Save vitorio/01fc2ce8857012b5a0a7f6c1b014c08a to your computer and use it in GitHub Desktop.
Save vitorio/01fc2ce8857012b5a0a7f6c1b014c08a to your computer and use it in GitHub Desktop.
Force a kiosk into BIOS to boot from a USB drive, Adafruit Trinkey QT2040, CircuitPython 8.x
import board
import digitalio
import storage
import usb_cdc
import usb_midi
import usb_hid
# QT2040 Trinkey
button = digitalio.DigitalInOut(board.BUTTON)
button.switch_to_input(digitalio.Pull.UP)
# If the button is NOT pressed, set up the BIOS keyboard
if button.value:
storage.disable_usb_drive()
usb_cdc.disable()
usb_midi.disable()
usb_hid.enable((usb_hid.Device.KEYBOARD), boot_device=1)
else:
pass
import board
import digitalio
import supervisor
import usb_hid
import time
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
# QT2040 Trinkey
button = digitalio.DigitalInOut(board.BUTTON)
button.switch_to_input(digitalio.Pull.UP)
# Don't autoreload, since we have to hold the button to boot normally
supervisor.runtime.autoreload = False
# If the button is NOT pressed, wait for USB then send keys
if button.value:
while not supervisor.runtime.usb_connected:
pass
kbd = Keyboard(usb_hid.devices)
# Mash DELETE 20 times to get into BIOS
for a in range(20):
kbd.send(Keycode.DELETE)
time.sleep(0.25)
time.sleep(5)
# F6 is Advanced Settings
kbd.send(Keycode.F6)
time.sleep(1)
# Left Arrow moves us to the exit screen
kbd.send(Keycode.LEFT_ARROW)
time.sleep(1)
# End moves us to the flash drive
kbd.send(Keycode.END)
time.sleep(1)
# Enter boots
kbd.send(Keycode.ENTER)
else:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment