Skip to content

Commit 76eb245

Browse files
committed
ssd1306: Make it work again
This was based on the old PyBoard I2C methods. Now it is using the recentmethods for I2C. Also: Fix init setting for 64x32 displays.
1 parent d574024 commit 76eb245

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

drivers/display/ssd1306.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def init_display(self):
4646
SET_MUX_RATIO, self.height - 1,
4747
SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0
4848
SET_DISP_OFFSET, 0x00,
49-
SET_COM_PIN_CFG, 0x02 if self.height == 32 else 0x12,
49+
SET_COM_PIN_CFG, 0x02 if self.width > 2 * self.height else 0x12,
5050
# timing and driving scheme
5151
SET_DISP_CLK_DIV, 0x80,
5252
SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,
@@ -104,13 +104,7 @@ def write_cmd(self, cmd):
104104
self.i2c.writeto(self.addr, self.temp)
105105

106106
def write_data(self, buf):
107-
self.temp[0] = self.addr << 1
108-
self.temp[1] = 0x40 # Co=0, D/C#=1
109-
self.i2c.start()
110-
self.i2c.write(self.temp)
111-
self.i2c.write(buf)
112-
self.i2c.stop()
113-
107+
self.i2c.writeto(self.addr, b'\x40' + buf)
114108

115109
class SSD1306_SPI(SSD1306):
116110
def __init__(self, width, height, spi, dc, res, cs, external_vcc=False):

0 commit comments

Comments
 (0)