Skip to content
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