diff --git a/adafruit_ssd1305.py b/adafruit_ssd1305.py index 2b2af87..157be54 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 @@ -238,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: @@ -281,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) @@ -296,6 +301,7 @@ def __init__( height, external_vcc=external_vcc, reset=reset, + col=col, ) def write_cmd(self, cmd: int) -> None: