Skip to content

optional column offset #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions adafruit_ssd1305.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -296,6 +301,7 @@ def __init__(
height,
external_vcc=external_vcc,
reset=reset,
col=col,
)

def write_cmd(self, cmd: int) -> None:
Expand Down