Skip to content
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

Add support for 72x40 SSD1306B #49

Merged
merged 3 commits into from
Oct 2, 2024
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
34 changes: 31 additions & 3 deletions adafruit_displayio_ssd1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* `Adafruit FeatherWing OLED - 128x32 OLED <https://www.adafruit.com/product/2900>`_
* Monochrome 0.49" 64x32 I2C OLED graphic display
* Monochrome 0.66" 64x48 I2C OLED graphic display (eg https://www.amazon.com/gp/product/B07QF7QK6P)
* Miniature 0.42" OLED 72x40 Display with Resin Lens
* https://tindie.com/products/questwise-ventures/miniature-042-oled-72x40-display-with-resin-lens
* Might work on other sub-128 width display: Dots 72x40, 64x48, 96x16

**Software and Dependencies:**
Expand Down Expand Up @@ -88,9 +90,35 @@ def __init__(self, bus: Union[FourWire, I2CDisplayBus], **kwargs) -> None:
col_offset = (
0 if width == 128 else (128 - width) // 2
) # https://github.com/micropython/micropython/pull/7411
row_offset = (
col_offset if (kwargs["height"] != 48 or kwargs["width"] != 64) else 0
) # fix for 0.66" 64x48 OLED
row_offset = col_offset

# for 64x48
if kwargs["height"] == 48 and kwargs["width"] == 64:
col_offset = (128 - kwargs["width"]) // 2
row_offset = 0

if "rotation" in kwargs and kwargs["rotation"] % 180 != 0:
init_sequence[16] = kwargs["height"] - 1
kwargs["height"] = height
kwargs["width"] = width

# for 72x40
if kwargs["height"] == 40 and kwargs["width"] == 72:
col_offset = (128 - kwargs["width"]) // 2
row_offset = 0

# add Internal IREF Setting for the 0.42 OLED as per
# https://github.com/olikraus/u8g2/issues/1047 and
# SSD1306B rev 1.1 datasheet at
# https://www.buydisplay.com/download/ic/SSD1306.pdf
seq_length = len(init_sequence) - 2
init_sequence[seq_length:seq_length] = bytearray(b"\xad\x01\x30")

if "rotation" in kwargs and kwargs["rotation"] % 180 != 0:
init_sequence[16] = kwargs["height"] - 1
kwargs["height"] = height
kwargs["width"] = width

super().__init__(
bus,
init_sequence,
Expand Down