diff --git a/adafruit_ssd1306.py b/adafruit_ssd1306.py index 949fef1..5c7e12a 100644 --- a/adafruit_ssd1306.py +++ b/adafruit_ssd1306.py @@ -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 ( @@ -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""" @@ -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"""