|
23 | 23 | * `Adafruit FeatherWing OLED - 128x32 OLED <https://www.adafruit.com/product/2900>`_
|
24 | 24 | * Monochrome 0.49" 64x32 I2C OLED graphic display
|
25 | 25 | * 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 |
26 | 28 | * Might work on other sub-128 width display: Dots 72x40, 64x48, 96x16
|
27 | 29 |
|
28 | 30 | **Software and Dependencies:**
|
@@ -88,9 +90,35 @@ def __init__(self, bus: Union[FourWire, I2CDisplayBus], **kwargs) -> None:
|
88 | 90 | col_offset = (
|
89 | 91 | 0 if width == 128 else (128 - width) // 2
|
90 | 92 | ) # 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 | + |
94 | 122 | super().__init__(
|
95 | 123 | bus,
|
96 | 124 | init_sequence,
|
|
0 commit comments