Skip to content

Commit 2862d77

Browse files
authored
Merge pull request #46 from kalehmann/fix-45/wake-display-during-init
Resolve #45: Ensure the display is awake after initialization
2 parents 835990e + 2c681aa commit 2862d77

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

adafruit_macropad.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
ROTATED_KEYMAP_180 = (11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
9494
ROTATED_KEYMAP_270 = (9, 6, 3, 0, 10, 7, 4, 1, 11, 8, 5, 2)
9595

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

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

295299
# Define audio:
@@ -340,11 +344,10 @@ def display_sleep(self) -> bool:
340344
def display_sleep(self, sleep: bool) -> None:
341345
if self._display_sleep == sleep:
342346
return
343-
# See https://cdn-shop.adafruit.com/product-files/5228/5223-ds.pdf#page=13
344347
if sleep:
345-
command = 0xAE
348+
command = _DISPLAY_SLEEP_COMMAND
346349
else:
347-
command = 0xAF
350+
command = _DISPLAY_WAKE_COMMAND
348351
self.display.bus.send(command, b"")
349352
self._display_sleep = sleep
350353

0 commit comments

Comments
 (0)