Skip to content

Commit

Permalink
Fix 96x16 OLED panel offset (#368)
Browse files Browse the repository at this point in the history
* Fix 96x16 OLED panel offset. (Fixes #367.)

* Fix 96x16 tests to match _colstart=0 for these displays.

* Adds @gsmecher to contributors list.

---------

Co-authored-by: Richard Hull <rm_hull@yahoo.co.uk>
  • Loading branch information
gsmecher and rm-hull committed Mar 16, 2023
1 parent 0893d24 commit 72440da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ Contributors
* Dhrone (@dhrone)
* George Harker (@georgeharker)
* @Pako2

* Graeme Smecher (@gsmecher)
12 changes: 6 additions & 6 deletions luma/oled/device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ def __init__(self, serial_interface=None, width=128, height=64, rotate=0, **kwar

# Supported modes
settings = {
(128, 64): dict(multiplex=0x3F, displayclockdiv=0x80, compins=0x12),
(128, 32): dict(multiplex=0x1F, displayclockdiv=0x80, compins=0x02),
(96, 16): dict(multiplex=0x0F, displayclockdiv=0x60, compins=0x02),
(64, 48): dict(multiplex=0x2F, displayclockdiv=0x80, compins=0x12),
(64, 32): dict(multiplex=0x1F, displayclockdiv=0x80, compins=0x12)
(128, 64): dict(multiplex=0x3F, displayclockdiv=0x80, compins=0x12, colstart=0),
(128, 32): dict(multiplex=0x1F, displayclockdiv=0x80, compins=0x02, colstart=0),
(96, 16): dict(multiplex=0x0F, displayclockdiv=0x60, compins=0x02, colstart=0),
(64, 48): dict(multiplex=0x2F, displayclockdiv=0x80, compins=0x12, colstart=32),
(64, 32): dict(multiplex=0x1F, displayclockdiv=0x80, compins=0x12, colstart=32)
}.get((width, height))

if settings is None:
Expand All @@ -255,7 +255,7 @@ def __init__(self, serial_interface=None, width=128, height=64, rotate=0, **kwar
self._pages = height // 8
self._mask = [1 << (i // width) % 8 for i in range(width * height)]
self._offsets = [(width * (i // (width * 8))) + (i % width) for i in range(width * height)]
self._colstart = (0x80 - self._w) // 2
self._colstart = settings['colstart']
self._colend = self._colstart + self._w

self.command(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ssd1306.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_init_96x16():
# set contrast
call(129, 207),
# reset the display
call(33, 16, 111, 34, 0, 1),
call(33, 0, 95, 34, 0, 1),
# called last, is a command to show the screen
call(175)
])
Expand Down

0 comments on commit 72440da

Please sign in to comment.