From 983b0a5ca412dc7d345157131a3453cc9a4c17ad Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 16 Aug 2022 03:29:36 +0200 Subject: [PATCH 1/3] last_received_report will be removed in Circuitpython 8.0.0 --- adafruit_hid/keyboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_hid/keyboard.py b/adafruit_hid/keyboard.py index f1240c3..403a3cb 100644 --- a/adafruit_hid/keyboard.py +++ b/adafruit_hid/keyboard.py @@ -162,7 +162,7 @@ def _remove_keycode_from_report(self, keycode: int) -> None: @property def led_status(self) -> bytes: """Returns the last received report""" - return self._keyboard_device.last_received_report + return self._keyboard_device.get_last_received_report() def led_on(self, led_code: int) -> bool: """Returns whether an LED is on based on the led code From 6cfc078467593e3b113cc29ee39916077e27f957 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 16 Aug 2022 03:44:42 +0200 Subject: [PATCH 2/3] handle a None out report --- adafruit_hid/keyboard.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adafruit_hid/keyboard.py b/adafruit_hid/keyboard.py index 403a3cb..6bcc726 100644 --- a/adafruit_hid/keyboard.py +++ b/adafruit_hid/keyboard.py @@ -162,7 +162,8 @@ def _remove_keycode_from_report(self, keycode: int) -> None: @property def led_status(self) -> bytes: """Returns the last received report""" - return self._keyboard_device.get_last_received_report() + # get_last_received_report() returns None when nothing was received + return self._keyboard_device.get_last_received_report() or b'\x00' def led_on(self, led_code: int) -> bool: """Returns whether an LED is on based on the led code @@ -174,7 +175,7 @@ def led_on(self, led_code: int) -> bool: from adafruit_hid.keycode import Keycode import time - # Initialize Keybaord + # Initialize Keyboard kbd = Keyboard(usb_hid.devices) # Press and release CapsLock. From 9a65eacb28e34f943487b4f2f558685fff11eaa8 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 16 Aug 2022 03:48:47 +0200 Subject: [PATCH 3/3] pre-commit --- adafruit_hid/keyboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_hid/keyboard.py b/adafruit_hid/keyboard.py index 6bcc726..ad46ef6 100644 --- a/adafruit_hid/keyboard.py +++ b/adafruit_hid/keyboard.py @@ -163,7 +163,7 @@ def _remove_keycode_from_report(self, keycode: int) -> None: def led_status(self) -> bytes: """Returns the last received report""" # get_last_received_report() returns None when nothing was received - return self._keyboard_device.get_last_received_report() or b'\x00' + return self._keyboard_device.get_last_received_report() or b"\x00" def led_on(self, led_code: int) -> bool: """Returns whether an LED is on based on the led code