File tree Expand file tree Collapse file tree 4 files changed +65
-3
lines changed
Expand file tree Collapse file tree 4 files changed +65
-3
lines changed Original file line number Diff line number Diff line change @@ -41,3 +41,7 @@ class ConsumerControlCode:
4141 """Decrease volume"""
4242 VOLUME_INCREMENT = 0xE9
4343 """Increase volume"""
44+ BRIGHTNESS_DECREMENT = 0x70
45+ """Decrease Brightness"""
46+ BRIGHTNESS_INCREMENT = 0x6F
47+ """Increase Brightness"""
Original file line number Diff line number Diff line change @@ -3,18 +3,42 @@ Simple test
33
44Ensure your device works with this simple test.
55
6+ .. literalinclude :: ../examples/hid_simpletest.py
7+ :caption: examples/hid_simpletest.py
8+ :linenos:
9+
10+ Keyboard Shortcuts
11+ -------------------
12+
13+ Send ALT+Tab for swapping windows, and CTRL+K for searching in a browser.
14+
615.. literalinclude :: ../examples/hid_keyboard_shortcuts.py
716 :caption: examples/hid_keyboard_shortcuts.py
817 :linenos:
918
10- .. literalinclude :: ../examples/hid_simpletest.py
11- :caption: examples/hid_simpletest.py
12- :linenos:
19+ Simple Gamepad
20+ ---------------
21+
22+ Send gamepad buttons and joystick to the host.
1323
1424.. literalinclude :: ../examples/hid_simple_gamepad.py
1525 :caption: examples/hid_simple_gamepad.py
1626 :linenos:
1727
28+ HID Joywing
29+ ------------
30+
31+ Use Joy FeatherWing to drive Gamepad.
32+
1833.. literalinclude :: ../examples/hid_joywing_gamepad.py
1934 :caption: examples/hid_joywing_gamepad.py
2035 :linenos:
36+
37+ Consumer Control Brightness
38+ ----------------------------
39+
40+ Send brightness up and down consumer codes to the host.
41+
42+ .. literalinclude :: ../examples/hid_consumer_control_brightness.py
43+ :caption: examples/hid_consumer_control_brightness.py
44+ :linenos:
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2021 Tim C for Adafruit Industries
2+ # SPDX-License-Identifier: MIT
3+
4+ import time
5+ import board
6+ import digitalio
7+ import usb_hid
8+ from adafruit_hid .consumer_control import ConsumerControl
9+ from adafruit_hid .consumer_control_code import ConsumerControlCode
10+
11+ cc = ConsumerControl (usb_hid .devices )
12+
13+ # define buttons. these can be any physical switches/buttons, but the values
14+ # here work out-of-the-box with a FunHouse UP and DOWN buttons.
15+ button_up = digitalio .DigitalInOut (board .BUTTON_UP )
16+ button_up .switch_to_input (pull = digitalio .Pull .DOWN )
17+
18+ button_down = digitalio .DigitalInOut (board .BUTTON_DOWN )
19+ button_down .switch_to_input (pull = digitalio .Pull .DOWN )
20+
21+ while True :
22+ if button_up .value :
23+ print ("Button up pressed!" )
24+ # send brightness up button press
25+ cc .send (ConsumerControlCode .BRIGHTNESS_INCREMENT )
26+
27+ if button_down .value :
28+ print ("Button down pressed!" )
29+ # send brightness down button press
30+ cc .send (ConsumerControlCode .BRIGHTNESS_DECREMENT )
31+
32+ time .sleep (0.1 )
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: MIT
33
44# Use Joy FeatherWing to drive Gamepad.
5+ # https://www.adafruit.com/product/3632
6+ # https://learn.adafruit.com/joy-featherwing
57
68import time
79
You can’t perform that action at this time.
0 commit comments