Skip to content

Commit 6717b68

Browse files
authored
Merge pull request #36 from TinyCircuits/master
Add 0.42" Screen Compatibility
2 parents 4503e95 + e935e6c commit 6717b68

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adafruit_ssd1306.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def init_display(self):
9999
SET_MUX_RATIO, self.height - 1,
100100
SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0
101101
SET_DISP_OFFSET, 0x00,
102-
SET_COM_PIN_CFG, 0x02 if self.height == 32 else 0x12,
102+
SET_COM_PIN_CFG, 0x02 if self.height == 32 or self.height == 16 else 0x12,
103103
# timing and driving scheme
104104
SET_DISP_CLK_DIV, 0x80,
105105
SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,
@@ -112,6 +112,9 @@ def init_display(self):
112112
SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,
113113
SET_DISP | 0x01): # on
114114
self.write_cmd(cmd)
115+
if self.width == 72:
116+
self.write_cmd(0xAD)
117+
self.write_cmd(0x30)
115118
self.fill(0)
116119
self.show()
117120

@@ -157,6 +160,10 @@ def show(self):
157160
# displays with width of 64 pixels are shifted by 32
158161
xpos0 += 32
159162
xpos1 += 32
163+
if self.width == 72:
164+
# displays with width of 72 pixels are shifted by 28
165+
xpos0 += 28
166+
xpos1 += 28
160167
self.write_cmd(SET_COL_ADDR)
161168
self.write_cmd(xpos0)
162169
self.write_cmd(xpos1)

0 commit comments

Comments
 (0)