Skip to content

Commit b92bf18

Browse files
committed
Adds support for the smaller 64x32 ssd1306 displays
1 parent e385444 commit b92bf18

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

adafruit_ssd1306.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def power(self):
8989

9090
def init_display(self):
9191
"""Base class to initialize display"""
92+
# The various screen sizes available with the ssd1306 OLED driver
93+
# chip require differing configuration values for the display clock
94+
# div and com pin, which are listed below for reference and future
95+
# compatibility:
96+
# w, h: DISP_CLK_DIV COM_PIN_CFG
97+
# 128, 64: 0x80 0x12
98+
# 128, 32: 0x80 0x02
99+
# 96, 16: 0x60 0x02
100+
# 64, 48: 0x80 0x12
101+
# 64, 32: 0x80 0x12
92102
for cmd in (
93103
SET_DISP | 0x00, # off
94104
# address setting
@@ -103,7 +113,7 @@ def init_display(self):
103113
SET_DISP_OFFSET,
104114
0x00,
105115
SET_COM_PIN_CFG,
106-
0x02 if self.height == 32 or self.height == 16 else 0x12,
116+
0x02 if (self.height == 32 or self.height == 16) and (self.width != 64) else 0x12,
107117
# timing and driving scheme
108118
SET_DISP_CLK_DIV,
109119
0x80,

0 commit comments

Comments
 (0)