Skip to content

Commit 71d40be

Browse files
committed
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.
1 parent 2646728 commit 71d40be

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

adafruit_ssd1305.py

Lines changed: 8 additions & 5 deletions
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

0 commit comments

Comments
 (0)