@@ -243,7 +243,6 @@ def __init__(
243243 layout_class : type [KeyboardLayoutBase ] = KeyboardLayoutUS ,
244244 keycode_class : type [Keycode ] = Keycode ,
245245 ):
246-
247246 if rotation not in (0 , 90 , 180 , 270 ):
248247 raise ValueError ("Only 90 degree rotations are supported." )
249248
@@ -291,6 +290,7 @@ def _keys_and_pixels(
291290 if not isinstance (board .DISPLAY , type (None )):
292291 self .display = board .DISPLAY
293292 self .display .rotation = rotation
293+ self ._display_sleep = False
294294
295295 # Define audio:
296296 self ._speaker_enable = digitalio .DigitalInOut (board .SPEAKER_ENABLE )
@@ -324,6 +324,30 @@ def _keys_and_pixels(
324324 # No MIDI ports available.
325325 self ._midi = None
326326
327+ @property
328+ def display_sleep (self ) -> bool :
329+ """The power saver mode of the display. Set it to put the display to
330+ sleep or wake it up again.
331+
332+ If the display is put to sleep, it stops the OLED drive and greatly
333+ reduces its power usage. The display mode and current content of the
334+ display are still kept in the memory of the displays microprocessor and
335+ can be updated nevertheless.
336+ """
337+ return self ._display_sleep
338+
339+ @display_sleep .setter
340+ def display_sleep (self , sleep : bool ) -> None :
341+ if self ._display_sleep == sleep :
342+ return
343+ # See https://cdn-shop.adafruit.com/product-files/5228/5223-ds.pdf#page=13
344+ if sleep :
345+ command = 0xAE
346+ else :
347+ command = 0xAF
348+ self .display .bus .send (command , b"" )
349+ self ._display_sleep = sleep
350+
327351 @property
328352 def pixels (self ) -> Optional [_PixelMapLite ]:
329353 """Sequence-like object representing the twelve NeoPixel LEDs in a 3 x 4 grid on the
0 commit comments