Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2# SPDX-FileCopyrightText: Copyright (c) 2021 Neradoc
3#
4# SPDX-License-Identifier: Unlicense
5
6import time
7import board
8import digitalio
9import usb_hid
10from adafruit_hid.consumer_control import ConsumerControl
11from consumer_control_extended import AL_TEXT_EDITOR, AL_CALCULATOR
12
13cc = ConsumerControl(usb_hid.devices)
14
15# define buttons. these can be any physical switches/buttons, but the values
16# here work out-of-the-box with a FunHouse UP and DOWN buttons.
17button_up = digitalio.DigitalInOut(board.BUTTON_UP)
18button_up.switch_to_input(pull=digitalio.Pull.DOWN)
19
20button_down = digitalio.DigitalInOut(board.BUTTON_DOWN)
21button_down.switch_to_input(pull=digitalio.Pull.DOWN)
22
23while True:
24 if button_up.value:
25 print("Button up pressed!")
26 # open the system text editor
27 cc.send(AL_TEXT_EDITOR)
28
29 if button_down.value:
30 print("Button down pressed!")
31 # open the calculator
32 cc.send(AL_CALCULATOR)
33
34 time.sleep(0.2)