@@ -243,7 +243,6 @@ def __init__(
243
243
layout_class : type [KeyboardLayoutBase ] = KeyboardLayoutUS ,
244
244
keycode_class : type [Keycode ] = Keycode ,
245
245
):
246
-
247
246
if rotation not in (0 , 90 , 180 , 270 ):
248
247
raise ValueError ("Only 90 degree rotations are supported." )
249
248
@@ -291,6 +290,7 @@ def _keys_and_pixels(
291
290
if not isinstance (board .DISPLAY , type (None )):
292
291
self .display = board .DISPLAY
293
292
self .display .rotation = rotation
293
+ self ._display_sleep = False
294
294
295
295
# Define audio:
296
296
self ._speaker_enable = digitalio .DigitalInOut (board .SPEAKER_ENABLE )
@@ -324,6 +324,25 @@ def _keys_and_pixels(
324
324
# No MIDI ports available.
325
325
self ._midi = None
326
326
327
+ @property
328
+ def display_sleep (self ) -> bool :
329
+ """Whether the display is currently asleep."""
330
+ return self ._display_sleep
331
+
332
+ @display_sleep .setter
333
+ def display_sleep (self , sleep : bool ) -> None :
334
+ """Change the sleep status of the display.
335
+
336
+ If the display is put to sleep, it stops the OLED drive and greatly
337
+ reduces its power usage. The current content of the display is kept
338
+ in the memory and can still be updated.
339
+ """
340
+ if self ._display_sleep == sleep :
341
+ return
342
+ command = 0xAE if sleep else 0xAF
343
+ self .display .bus .send (command , b"" )
344
+ self ._display_sleep = sleep
345
+
327
346
@property
328
347
def pixels (self ) -> Optional [_PixelMapLite ]:
329
348
"""Sequence-like object representing the twelve NeoPixel LEDs in a 3 x 4 grid on the
0 commit comments