Skip to content

Commit ca2427c

Browse files
committed
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.
1 parent 7df4083 commit ca2427c

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/display/ssd1306.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# MicroPython SSD1306 OLED driver, I2C and SPI interfaces
22

33
from micropython import const
4-
import time
54
import framebuf
65

76

@@ -47,7 +46,6 @@ def __init__(self, width, height, external_vcc):
4746
self.text = fb.text
4847
self.scroll = fb.scroll
4948
self.blit = fb.blit
50-
self.poweron()
5149
self.init_display()
5250

5351
def init_display(self):
@@ -80,6 +78,9 @@ def init_display(self):
8078
def poweroff(self):
8179
self.write_cmd(SET_DISP | 0x00)
8280

81+
def poweron(self):
82+
self.write_cmd(SET_DISP | 0x01)
83+
8384
def contrast(self, contrast):
8485
self.write_cmd(SET_CONTRAST)
8586
self.write_cmd(contrast)
@@ -123,9 +124,6 @@ def write_data(self, buf):
123124
self.i2c.write(buf)
124125
self.i2c.stop()
125126

126-
def poweron(self):
127-
self.write_cmd(SET_DISP | 0x01)
128-
129127

130128
class SSD1306_SPI(SSD1306):
131129
def __init__(self, width, height, spi, dc, res, cs, external_vcc=False):
@@ -137,6 +135,12 @@ def __init__(self, width, height, spi, dc, res, cs, external_vcc=False):
137135
self.dc = dc
138136
self.res = res
139137
self.cs = cs
138+
import time
139+
self.res(1)
140+
time.sleep_ms(1)
141+
self.res(0)
142+
time.sleep_ms(10)
143+
self.res(1)
140144
super().__init__(width, height, external_vcc)
141145

142146
def write_cmd(self, cmd):
@@ -154,10 +158,3 @@ def write_data(self, buf):
154158
self.cs(0)
155159
self.spi.write(buf)
156160
self.cs(1)
157-
158-
def poweron(self):
159-
self.res(1)
160-
time.sleep_ms(1)
161-
self.res(0)
162-
time.sleep_ms(10)
163-
self.res(1)

0 commit comments

Comments
 (0)