Skip to content

Commit a72bc77

Browse files
authored
Merge pull request #16 from mikeysklar/ssd1305-white-module-col-offset
optional column offset
2 parents 2646728 + 7ee9a18 commit a72bc77

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

adafruit_ssd1305.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def __init__(
8787
height: int,
8888
*,
8989
external_vcc: bool,
90-
reset: Optional[DigitalInOut]
90+
reset: Optional[DigitalInOut],
91+
col: Optional[int] = None # Shortened argument name
9192
):
9293
super().__init__(buffer, width, height)
9394
self.width = width
@@ -98,9 +99,10 @@ def __init__(
9899
if self.reset_pin:
99100
self.reset_pin.switch_to_output(value=False)
100101
self.pages = self.height // 8
101-
self._column_offset = 0
102-
if self.height == 32:
103-
self._column_offset = 4 # hardcoded for now...
102+
103+
# Set default column offset, allow override
104+
self._column_offset = col if col is not None else 4
105+
104106
# Note the subclass must initialize self.framebuf to a framebuffer.
105107
# This is necessary because the underlying data buffer is different
106108
# between I2C and SPI implementations (I2C needs an extra byte).
@@ -220,7 +222,8 @@ def __init__(
220222
*,
221223
addr: int = 0x3C,
222224
external_vcc: bool = False,
223-
reset: Optional[DigitalInOut] = None
225+
reset: Optional[DigitalInOut] = None,
226+
col=None
224227
):
225228
self.i2c_device = i2c_device.I2CDevice(i2c, addr)
226229
self.addr = addr
@@ -238,6 +241,7 @@ def __init__(
238241
height,
239242
external_vcc=external_vcc,
240243
reset=reset,
244+
col=col, # <-- Forwarded col parameter to base class
241245
)
242246

243247
def write_cmd(self, cmd: int) -> None:
@@ -281,7 +285,8 @@ def __init__(
281285
external_vcc: bool = False,
282286
baudrate: int = 8000000,
283287
polarity: int = 0,
284-
phase: int = 0
288+
phase: int = 0,
289+
col=None
285290
):
286291
self.rate = 10 * 1024 * 1024
287292
dc.switch_to_output(value=False)
@@ -296,6 +301,7 @@ def __init__(
296301
height,
297302
external_vcc=external_vcc,
298303
reset=reset,
304+
col=col,
299305
)
300306

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

0 commit comments

Comments
 (0)