Skip to content

Commit c997737

Browse files
authored
Merge pull request #26 from iraytrace/master
add power property to _SSD1306
2 parents 6bc92de + 619e598 commit c997737

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

adafruit_ssd1306.py

+8
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ 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+
"""True if the display is currently powered on, otherwise False"""
88+
return self._power
89+
8490
def init_display(self):
8591
"""Base class to initialize display"""
8692
for cmd in (
@@ -112,6 +118,7 @@ def init_display(self):
112118
def poweroff(self):
113119
"""Turn off the display (nothing visible)"""
114120
self.write_cmd(SET_DISP | 0x00)
121+
self._power = False
115122

116123
def contrast(self, contrast):
117124
"""Adjust the contrast"""
@@ -140,6 +147,7 @@ def poweron(self):
140147
self.reset_pin.value = 1
141148
time.sleep(0.010)
142149
self.write_cmd(SET_DISP | 0x01)
150+
self._power = True
143151

144152
def show(self):
145153
"""Update the display"""

0 commit comments

Comments
 (0)