Skip to content

Commit 41014aa

Browse files
authored
Merge pull request #9 from lesamouraipourpre/multiplex
Revert the multiplex ratio to 0x7F
2 parents 1837b47 + d1e15a7 commit 41014aa

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

adafruit_displayio_sh1107.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
b"\x20\x00" # vertical (column) addressing mode (POR=0x20)
9797
b"\xa0\x00" # segment remap = 1 (POR=0, down rotation)
9898
b"\xc0\x00" # common output scan direction = 0 (0 to n-1 (POR=0))
99-
b"\xa8\x01\x3f" # multiplex ratio = 64 (POR=0x7F)
99+
b"\xa8\x01\x7f" # multiplex ratio = 128 (POR=0x7F)
100100
b"\xd3\x01\x60" # set display offset mode = 0x60
101101
# b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
102102
b"\xd9\x01\x22" # pre-charge/dis-charge period mode: 2 DCLKs/2 DCLKs (POR)
@@ -131,7 +131,13 @@ def __init__(
131131
rotation=0,
132132
**kwargs
133133
):
134+
rotation = (rotation + _ROTATION_OFFSET) % 360
135+
if rotation in (0, 180):
136+
multiplex = kwargs["width"] - 1
137+
else:
138+
multiplex = kwargs["height"] - 1
134139
init_sequence = bytearray(_INIT_SEQUENCE)
140+
init_sequence[16] = multiplex
135141
init_sequence[19] = display_offset
136142
super().__init__(
137143
bus,
@@ -143,7 +149,7 @@ def __init__(
143149
data_as_commands=True, # every byte will have a command byte preceding
144150
brightness_command=0x81,
145151
single_byte_bounds=True,
146-
rotation=(rotation + _ROTATION_OFFSET) % 360,
152+
rotation=rotation,
147153
# for sh1107 use column and page addressing.
148154
# lower column command = 0x00 - 0x0F
149155
# upper column command = 0x10 - 0x17

0 commit comments

Comments
 (0)