Skip to content

Commit d7de7c8

Browse files
authored
Merge pull request #49 from asmagill/main
Add support for 72x40 SSD1306B
2 parents aba9b4f + 4c90ec3 commit d7de7c8

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

adafruit_displayio_ssd1306.py

+31-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* `Adafruit FeatherWing OLED - 128x32 OLED <https://www.adafruit.com/product/2900>`_
2424
* Monochrome 0.49" 64x32 I2C OLED graphic display
2525
* Monochrome 0.66" 64x48 I2C OLED graphic display (eg https://www.amazon.com/gp/product/B07QF7QK6P)
26+
* Miniature 0.42" OLED 72x40 Display with Resin Lens
27+
* https://tindie.com/products/questwise-ventures/miniature-042-oled-72x40-display-with-resin-lens
2628
* Might work on other sub-128 width display: Dots 72x40, 64x48, 96x16
2729
2830
**Software and Dependencies:**
@@ -88,9 +90,35 @@ def __init__(self, bus: Union[FourWire, I2CDisplayBus], **kwargs) -> None:
8890
col_offset = (
8991
0 if width == 128 else (128 - width) // 2
9092
) # https://github.com/micropython/micropython/pull/7411
91-
row_offset = (
92-
col_offset if (kwargs["height"] != 48 or kwargs["width"] != 64) else 0
93-
) # fix for 0.66" 64x48 OLED
93+
row_offset = col_offset
94+
95+
# for 64x48
96+
if kwargs["height"] == 48 and kwargs["width"] == 64:
97+
col_offset = (128 - kwargs["width"]) // 2
98+
row_offset = 0
99+
100+
if "rotation" in kwargs and kwargs["rotation"] % 180 != 0:
101+
init_sequence[16] = kwargs["height"] - 1
102+
kwargs["height"] = height
103+
kwargs["width"] = width
104+
105+
# for 72x40
106+
if kwargs["height"] == 40 and kwargs["width"] == 72:
107+
col_offset = (128 - kwargs["width"]) // 2
108+
row_offset = 0
109+
110+
# add Internal IREF Setting for the 0.42 OLED as per
111+
# https://github.com/olikraus/u8g2/issues/1047 and
112+
# SSD1306B rev 1.1 datasheet at
113+
# https://www.buydisplay.com/download/ic/SSD1306.pdf
114+
seq_length = len(init_sequence) - 2
115+
init_sequence[seq_length:seq_length] = bytearray(b"\xad\x01\x30")
116+
117+
if "rotation" in kwargs and kwargs["rotation"] % 180 != 0:
118+
init_sequence[16] = kwargs["height"] - 1
119+
kwargs["height"] = height
120+
kwargs["width"] = width
121+
94122
super().__init__(
95123
bus,
96124
init_sequence,

0 commit comments

Comments
 (0)