Skip to content

Commit 6b7b0d9

Browse files
author
Lee Butler
committed
add power property to _SSD1306
1 parent 836b872 commit 6b7b0d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

adafruit_ssd1306.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ def __init__(self, buffer, width, height, *, external_vcc, reset):
7878
# Note the subclass must initialize self.framebuf to a framebuffer.
7979
# This is necessary because the underlying data buffer is different
8080
# between I2C and SPI implementations (I2C needs an extra byte).
81+
self._power = False
8182
self.poweron()
8283
self.init_display()
8384

85+
@property
86+
def power(self):
87+
return self._power
88+
8489
def init_display(self):
8590
"""Base class to initialize display"""
8691
for cmd in (
@@ -112,6 +117,7 @@ def init_display(self):
112117
def poweroff(self):
113118
"""Turn off the display (nothing visible)"""
114119
self.write_cmd(SET_DISP | 0x00)
120+
self._power = False
115121

116122
def contrast(self, contrast):
117123
"""Adjust the contrast"""
@@ -140,6 +146,7 @@ def poweron(self):
140146
self.reset_pin.value = 1
141147
time.sleep(0.010)
142148
self.write_cmd(SET_DISP | 0x01)
149+
self._power = True
143150

144151
def show(self):
145152
"""Update the display"""
@@ -232,3 +239,4 @@ def write_framebuf(self):
232239
self.dc_pin.value = 1
233240
with self.spi_device as spi:
234241
spi.write(self.buffer)
242+

0 commit comments

Comments
 (0)