Skip to content

last_received_report will be removed in Circuitpython 8.0.0 #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions adafruit_hid/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.last_received_report
# get_last_received_report() returns None when nothing was received
return self._keyboard_device.get_last_received_report() or b"\x00"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation says that last_received_report also returned None, so is the or b"\00" just a bugfix? I'm assuming it MUST be a bytes object return instead of Optional based on usage in led_on. Just wanted to check before merging so I get the semver correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes the code compatible with the documentation. In reality last_received_report and get_last_received_report() never return None as currently implemented, but I added that to future-proof it a little in case that's fixed.
There might be bigger changes coming in 8.0.0 though, so that might be revisited soon.
See adafruit/circuitpython#6767


def led_on(self, led_code: int) -> bool:
"""Returns whether an LED is on based on the led code
Expand All @@ -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.
Expand Down