File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -291,6 +291,7 @@ def _keys_and_pixels(
291
291
if not isinstance (board .DISPLAY , type (None )):
292
292
self .display = board .DISPLAY
293
293
self .display .rotation = rotation
294
+ self ._display_sleep = False
294
295
295
296
# Define audio:
296
297
self ._speaker_enable = digitalio .DigitalInOut (board .SPEAKER_ENABLE )
@@ -324,6 +325,25 @@ def _keys_and_pixels(
324
325
# No MIDI ports available.
325
326
self ._midi = None
326
327
328
+ @property
329
+ def display_sleep (self ) -> bool :
330
+ """Whether the display is currently asleep."""
331
+ return self ._display_sleep
332
+
333
+ @display_sleep .setter
334
+ def display_sleep (self , sleep : bool ) -> None :
335
+ """Change the sleep status of the display.
336
+
337
+ If the display is put to sleep, it stops the OLED drive and greatly
338
+ reduces its power usage. The current content of the display is kept
339
+ in the memory and can still be updated.
340
+ """
341
+ if self ._display_sleep == sleep :
342
+ return
343
+ command = 0xAE if sleep else 0xAF
344
+ self .display .bus .send (command , b"" )
345
+ self ._display_sleep = sleep
346
+
327
347
@property
328
348
def pixels (self ) -> Optional [_PixelMapLite ]:
329
349
"""Sequence-like object representing the twelve NeoPixel LEDs in a 3 x 4 grid on the
You can’t perform that action at this time.
0 commit comments