Skip to content

Commit 9abe689

Browse files
committed
add led_status and led_on
1 parent c97664f commit 9abe689

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

adafruit_hid/keyboard.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
class Keyboard:
2323
"""Send HID keyboard reports."""
2424

25+
LED_NUM_LOCK = 0x01
26+
LED_CAPS_LOCK = 0x02
27+
LED_SCROLL_LOCK = 0x04
28+
LED_COMPOSE = 0x08
29+
2530
# No more than _MAX_KEYPRESSES regular keys may be pressed at once.
2631

2732
def __init__(self, devices):
@@ -143,3 +148,12 @@ def _remove_keycode_from_report(self, keycode):
143148
for i in range(_MAX_KEYPRESSES):
144149
if self.report_keys[i] == keycode:
145150
self.report_keys[i] = 0
151+
152+
@property
153+
def led_status(self):
154+
"""Returns the last received report"""
155+
return self._keyboard_device.last_received_report
156+
157+
def led_on(self, led_code):
158+
"""Returns whether an LED is on based on the led code"""
159+
return bool(self.led_status[0] & led_code)

0 commit comments

Comments
 (0)