Skip to content

Commit

Permalink
Merge pull request #19 from SAK917/master
Browse files Browse the repository at this point in the history
Implement SSD1306 sleep/wake functionality
  • Loading branch information
ladyada committed Feb 18, 2021
2 parents 62a513c + 1f6d0d7 commit 8226c2a
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions adafruit_displayio_ssd1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
b"\xda\x01\x12" # Set com configuration
b"\xdb\x01\x40" # Set vcom configuration
b"\x8d\x01\x14" # Enable charge pump
b"\xAF\x00\x00" # DISPLAY_ON
b"\xAF\x00" # DISPLAY_ON
)

# pylint: disable=too-few-public-methods

class SSD1306(displayio.Display):
"""SSD1306 driver"""

Expand All @@ -78,3 +78,33 @@ def __init__(self, bus, **kwargs):
brightness_command=0x81,
single_byte_bounds=True,
)
self._is_awake = True # Display starts in active state (_INIT_SEQUENCE)

@property
def is_awake(self):
"""
The power state of the display. (read-only)
True if the display is active, False if in sleep mode.
"""
return self._is_awake

def sleep(self):
"""
Put display into sleep mode
Display uses < 10uA in sleep mode
Display remembers display data and operation mode active prior to sleeping
MP can access (update) the built-in display RAM
"""
if self._is_awake:
self.bus.send(int(0xAE), "") # 0xAE = display off, sleep mode
self._is_awake = False

def wake(self):
"""
Wake display from sleep mode
"""
if not self._is_awake:
self.bus.send(int(0xAF), "") # 0xAF = display on
self._is_awake = True

0 comments on commit 8226c2a

Please sign in to comment.