Skip to content

Resolve #45: Ensure the display is awake after initialization #46

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 1 commit into from
May 3, 2023
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
9 changes: 6 additions & 3 deletions adafruit_macropad.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
ROTATED_KEYMAP_180 = (11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
ROTATED_KEYMAP_270 = (9, 6, 3, 0, 10, 7, 4, 1, 11, 8, 5, 2)

# See https://cdn-shop.adafruit.com/product-files/5228/5223-ds.pdf#page=13
_DISPLAY_SLEEP_COMMAND = 0xAE
_DISPLAY_WAKE_COMMAND = 0xAF

keycodes = Keycode
"""Module level Keycode class, to be changed when initing Macropad with a different language"""
Expand Down Expand Up @@ -290,6 +293,7 @@ def _keys_and_pixels(
if not isinstance(board.DISPLAY, type(None)):
self.display = board.DISPLAY
self.display.rotation = rotation
self.display.bus.send(_DISPLAY_WAKE_COMMAND, b"")
self._display_sleep = False

# Define audio:
Expand Down Expand Up @@ -340,11 +344,10 @@ def display_sleep(self) -> bool:
def display_sleep(self, sleep: bool) -> None:
if self._display_sleep == sleep:
return
# See https://cdn-shop.adafruit.com/product-files/5228/5223-ds.pdf#page=13
if sleep:
command = 0xAE
command = _DISPLAY_SLEEP_COMMAND
else:
command = 0xAF
command = _DISPLAY_WAKE_COMMAND
self.display.bus.send(command, b"")
self._display_sleep = sleep

Expand Down