From 16d621dad3209425fdd22fed63d55b2ebe2cb5d1 Mon Sep 17 00:00:00 2001 From: asmagill Date: Sun, 29 Sep 2024 01:34:03 -0500 Subject: [PATCH 1/3] Add support for 72x40 SSD1306B --- adafruit_displayio_ssd1306.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/adafruit_displayio_ssd1306.py b/adafruit_displayio_ssd1306.py index 3e67cfe..76cb417 100644 --- a/adafruit_displayio_ssd1306.py +++ b/adafruit_displayio_ssd1306.py @@ -23,6 +23,7 @@ * `Adafruit FeatherWing OLED - 128x32 OLED `_ * 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://www.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:** @@ -91,6 +92,24 @@ def __init__(self, bus: Union[FourWire, I2CDisplayBus], **kwargs) -> None: row_offset = ( col_offset if (kwargs["height"] != 48 or kwargs["width"] != 64) else 0 ) # fix for 0.66" 64x48 OLED + + # for 72x40 + if kwargs["height"] == 40 and kwargs["width"] == 72: + col_offset = 28 + 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, From f6de8b0379702ab71c30e4348fe3c3970ce7ca76 Mon Sep 17 00:00:00 2001 From: asmagill Date: Sun, 29 Sep 2024 16:49:34 -0500 Subject: [PATCH 2/3] apply same rotation logic to 64x48 --- adafruit_displayio_ssd1306.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/adafruit_displayio_ssd1306.py b/adafruit_displayio_ssd1306.py index 76cb417..5afd79c 100644 --- a/adafruit_displayio_ssd1306.py +++ b/adafruit_displayio_ssd1306.py @@ -89,13 +89,21 @@ 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 = 28 + col_offset = (128 - kwargs["width"]) // 2 row_offset = 0 # add Internal IREF Setting for the 0.42 OLED as per From 4c90ec3fe5528d184101a81e6ee0f4a2c357c4c6 Mon Sep 17 00:00:00 2001 From: asmagill Date: Tue, 1 Oct 2024 21:29:10 -0500 Subject: [PATCH 3/3] shorten tindie link for 72x40 --- adafruit_displayio_ssd1306.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_displayio_ssd1306.py b/adafruit_displayio_ssd1306.py index 5afd79c..5389282 100644 --- a/adafruit_displayio_ssd1306.py +++ b/adafruit_displayio_ssd1306.py @@ -23,7 +23,8 @@ * `Adafruit FeatherWing OLED - 128x32 OLED `_ * 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://www.tindie.com/products/questwise-ventures/miniature-042-oled-72x40-display-with-resin-lens/) +* 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:**