Last active
July 20, 2023 03:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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