-
Notifications
You must be signed in to change notification settings - Fork 23
Implement SSD1306 sleep/wake functionality #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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""" | ||
|
||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be part of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have a sleep API merged in for the SH1107 so let's leave this as-is so it's consistent: https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107/pull/2/files#diff-31026eacc758006ff27f43d9fff4ad747cdfd61cbd17dcb69e7e43eac020de2cR75 |
||
""" | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to
awake