blob: 1cf922c45f31713ff6d6a3c457b9ef6c4f99ebb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# SPDX-FileCopyrightText: 2021 Tim C for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import board
import digitalio
import usb_hid
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
cc = ConsumerControl(usb_hid.devices)
# define buttons. these can be any physical switches/buttons, but the values
# here work out-of-the-box with a FunHouse UP and DOWN buttons.
button_up = digitalio.DigitalInOut(board.BUTTON_UP)
button_up.switch_to_input(pull=digitalio.Pull.DOWN)
button_down = digitalio.DigitalInOut(board.BUTTON_DOWN)
button_down.switch_to_input(pull=digitalio.Pull.DOWN)
while True:
if button_up.value:
print("Button up pressed!")
# send brightness up button press
cc.send(ConsumerControlCode.BRIGHTNESS_INCREMENT)
if button_down.value:
print("Button down pressed!")
# send brightness down button press
cc.send(ConsumerControlCode.BRIGHTNESS_DECREMENT)
time.sleep(0.1)
|