From 71d40bee54a41ca908705d617a122aa62889ca3c Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Wed, 19 Mar 2025 19:51:16 -0700 Subject: [PATCH 1/5] optional column offset column offset had been hard coded to 4. An updated ADA# 2675 128x32 2.3" Monochrome OLED needs an offset of col=0 to work. Col=4 will remain default, but this override is for this one model which has changed. --- adafruit_ssd1305.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index 2b2af87..7109793 100644 --- a/adafruit_ssd1305.py +++ b/adafruit_ssd1305.py @@ -87,7 +87,8 @@ def __init__( height: int, *, external_vcc: bool, - reset: Optional[DigitalInOut] + reset: Optional[DigitalInOut], + col: Optional[int] = None # Shortened argument name ): super().__init__(buffer, width, height) self.width = width @@ -98,9 +99,10 @@ def __init__( if self.reset_pin: self.reset_pin.switch_to_output(value=False) self.pages = self.height // 8 - self._column_offset = 0 - if self.height == 32: - self._column_offset = 4 # hardcoded for now... + + # Set default column offset, allow override + self._column_offset = col if col is not None else 4 + # Note the subclass must initialize self.framebuf to a framebuffer. # This is necessary because the underlying data buffer is different # between I2C and SPI implementations (I2C needs an extra byte). @@ -220,7 +222,8 @@ def __init__( *, addr: int = 0x3C, external_vcc: bool = False, - reset: Optional[DigitalInOut] = None + reset: Optional[DigitalInOut] = None, + col = None ): self.i2c_device = i2c_device.I2CDevice(i2c, addr) self.addr = addr From 45cea61dcd19721f10f98b3655ef2dd690e9c862 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Wed, 19 Mar 2025 20:06:21 -0700 Subject: [PATCH 2/5] Update adafruit_ssd1305.py --- adafruit_ssd1305.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index 7109793..cfd5594 100644 --- a/adafruit_ssd1305.py +++ b/adafruit_ssd1305.py @@ -223,7 +223,7 @@ def __init__( addr: int = 0x3C, external_vcc: bool = False, reset: Optional[DigitalInOut] = None, - col = None + col=None ): self.i2c_device = i2c_device.I2CDevice(i2c, addr) self.addr = addr From 9a67470db2eec98c3aa3684084a1c32034827d08 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Fri, 21 Mar 2025 19:38:06 -0700 Subject: [PATCH 3/5] pass col= back to base class --- adafruit_ssd1305.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index cfd5594..5a17814 100644 --- a/adafruit_ssd1305.py +++ b/adafruit_ssd1305.py @@ -241,6 +241,7 @@ def __init__( height, external_vcc=external_vcc, reset=reset, + col=col # <-- Forwarded col parameter to base class ) def write_cmd(self, cmd: int) -> None: @@ -284,7 +285,8 @@ def __init__( external_vcc: bool = False, baudrate: int = 8000000, polarity: int = 0, - phase: int = 0 + phase: int = 0, + col=None ): self.rate = 10 * 1024 * 1024 dc.switch_to_output(value=False) @@ -299,6 +301,7 @@ def __init__( height, external_vcc=external_vcc, reset=reset, + col=col ) def write_cmd(self, cmd: int) -> None: From 0d6716c9266ae383f898800d3a8de4f45197b247 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Fri, 21 Mar 2025 19:48:52 -0700 Subject: [PATCH 4/5] linting --- adafruit_ssd1305.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index 5a17814..c8d9816 100644 --- a/adafruit_ssd1305.py +++ b/adafruit_ssd1305.py @@ -241,7 +241,7 @@ def __init__( height, external_vcc=external_vcc, reset=reset, - col=col # <-- Forwarded col parameter to base class + col=col, # <-- Forwarded col parameter to base class ) def write_cmd(self, cmd: int) -> None: @@ -301,7 +301,7 @@ def __init__( height, external_vcc=external_vcc, reset=reset, - col=col + col=col, ) def write_cmd(self, cmd: int) -> None: From 7ee9a184fd09575f99a18657d24e923debc956c7 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Fri, 21 Mar 2025 20:02:04 -0700 Subject: [PATCH 5/5] linting --- adafruit_ssd1305.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index c8d9816..157be54 100644 --- a/adafruit_ssd1305.py +++ b/adafruit_ssd1305.py @@ -241,7 +241,7 @@ def __init__( height, external_vcc=external_vcc, reset=reset, - col=col, # <-- Forwarded col parameter to base class + col=col, # <-- Forwarded col parameter to base class ) def write_cmd(self, cmd: int) -> None: