Skip to content

add power property to _SSD1306 #26

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

Merged
merged 4 commits into from
Sep 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions adafruit_ssd1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ def __init__(self, buffer, width, height, *, external_vcc, reset):
# Note the subclass must initialize self.framebuf to a framebuffer.
# This is necessary because the underlying data buffer is different
# between I2C and SPI implementations (I2C needs an extra byte).
self._power = False
self.poweron()
self.init_display()

@property
def power(self):
"""True if the display is currently powered on, otherwise False"""
return self._power

def init_display(self):
"""Base class to initialize display"""
for cmd in (
Expand Down Expand Up @@ -112,6 +118,7 @@ def init_display(self):
def poweroff(self):
"""Turn off the display (nothing visible)"""
self.write_cmd(SET_DISP | 0x00)
self._power = False

def contrast(self, contrast):
"""Adjust the contrast"""
Expand Down Expand Up @@ -140,6 +147,7 @@ def poweron(self):
self.reset_pin.value = 1
time.sleep(0.010)
self.write_cmd(SET_DISP | 0x01)
self._power = True

def show(self):
"""Update the display"""
Expand Down