diff options
| author | Damien George <damien.p.george@gmail.com> | 2017-10-06 12:45:16 +1100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2017-10-06 12:48:44 +1100 |
| commit | ca2427c31399834bcc7df6177b3314aa7242046e (patch) | |
| tree | 45a6fc0ea68ee55ccaeeb9deb4d150fbae717a05 /drivers/display/ssd1306.py | |
| parent | 7df4083ac6344944e895b5911d59b64b68c8c134 (diff) | |
drivers/display/ssd1306: Make poweron() work the same with SSD1306_SPI.
The poweroff() and poweron() methods are used to do soft power control of
the display, and this patch makes these methods work the same for both I2C
and SPI interfaces.
Diffstat (limited to 'drivers/display/ssd1306.py')
| -rw-r--r-- | drivers/display/ssd1306.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/display/ssd1306.py b/drivers/display/ssd1306.py index a05eda7df..cd358d00e 100644 --- a/drivers/display/ssd1306.py +++ b/drivers/display/ssd1306.py @@ -1,7 +1,6 @@ # MicroPython SSD1306 OLED driver, I2C and SPI interfaces from micropython import const -import time import framebuf @@ -47,7 +46,6 @@ class SSD1306: self.text = fb.text self.scroll = fb.scroll self.blit = fb.blit - self.poweron() self.init_display() def init_display(self): @@ -80,6 +78,9 @@ class SSD1306: def poweroff(self): self.write_cmd(SET_DISP | 0x00) + def poweron(self): + self.write_cmd(SET_DISP | 0x01) + def contrast(self, contrast): self.write_cmd(SET_CONTRAST) self.write_cmd(contrast) @@ -123,9 +124,6 @@ class SSD1306_I2C(SSD1306): self.i2c.write(buf) self.i2c.stop() - def poweron(self): - self.write_cmd(SET_DISP | 0x01) - class SSD1306_SPI(SSD1306): def __init__(self, width, height, spi, dc, res, cs, external_vcc=False): @@ -137,6 +135,12 @@ class SSD1306_SPI(SSD1306): self.dc = dc self.res = res self.cs = cs + import time + self.res(1) + time.sleep_ms(1) + self.res(0) + time.sleep_ms(10) + self.res(1) super().__init__(width, height, external_vcc) def write_cmd(self, cmd): @@ -154,10 +158,3 @@ class SSD1306_SPI(SSD1306): self.cs(0) self.spi.write(buf) self.cs(1) - - def poweron(self): - self.res(1) - time.sleep_ms(1) - self.res(0) - time.sleep_ms(10) - self.res(1) |
