Skip to content

Add 0.42" Screen Compatibility #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion adafruit_ssd1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def init_display(self):
SET_MUX_RATIO, self.height - 1,
SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0
SET_DISP_OFFSET, 0x00,
SET_COM_PIN_CFG, 0x02 if self.height == 32 else 0x12,
SET_COM_PIN_CFG, 0x02 if self.height == 32 or self.height == 16 else 0x12,
# timing and driving scheme
SET_DISP_CLK_DIV, 0x80,
SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,
Expand All @@ -112,6 +112,9 @@ def init_display(self):
SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,
SET_DISP | 0x01): # on
self.write_cmd(cmd)
if self.width == 72:
self.write_cmd(0xAD)
self.write_cmd(0x30)
self.fill(0)
self.show()

Expand Down Expand Up @@ -157,6 +160,10 @@ def show(self):
# displays with width of 64 pixels are shifted by 32
xpos0 += 32
xpos1 += 32
if self.width == 72:
# displays with width of 72 pixels are shifted by 28
xpos0 += 28
xpos1 += 28
self.write_cmd(SET_COL_ADDR)
self.write_cmd(xpos0)
self.write_cmd(xpos1)
Expand Down