@@ -61,7 +61,40 @@ def send(self, consumer_code):
61
61
# Advance to next track (song).
62
62
consumer_control.send(ConsumerControlCode.SCAN_NEXT_TRACK)
63
63
"""
64
+ self .press (consumer_code )
65
+ self .release ()
66
+
67
+ def press (self , consumer_code ):
68
+ """Send a report to indicate that the given key has been pressed.
69
+ Only one consumer control action can be pressed at a time, so any one
70
+ that was previously pressed will be released.
71
+
72
+ :param consumer_code: a 16-bit consumer control code.
73
+
74
+ Examples::
75
+
76
+ from adafruit_hid.consumer_control_code import ConsumerControlCode
77
+
78
+ # Raise volume for 0.5 seconds
79
+ consumer_control.press(ConsumerControlCode.VOLUME_INCREMENT)
80
+ time.sleep(0.5)
81
+ consumer_control.release()
82
+ """
64
83
struct .pack_into ("<H" , self ._report , 0 , consumer_code )
65
84
self ._consumer_device .send_report (self ._report )
85
+
86
+ def release (self ):
87
+ """Send a report indicating that the consumer control key has been
88
+ released. Only one consumer control key can be pressed at a time.
89
+
90
+ Examples::
91
+
92
+ from adafruit_hid.consumer_control_code import ConsumerControlCode
93
+
94
+ # Raise volume for 0.5 seconds
95
+ consumer_control.press(ConsumerControlCode.VOLUME_INCREMENT)
96
+ time.sleep(0.5)
97
+ consumer_control.release()
98
+ """
66
99
self ._report [0 ] = self ._report [1 ] = 0x0
67
100
self ._consumer_device .send_report (self ._report )
0 commit comments