Skip to content

Commit 56cac7a

Browse files
Merge remote-tracking branch 'origin/multiplex' into cpython
2 parents 8868384 + d1e15a7 commit 56cac7a

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
@@ -97,7 +97,7 @@
9797
b"\x20\x00" # vertical (column) addressing mode (POR=0x20)
9898
b"\xa0\x00" # segment remap = 1 (POR=0, down rotation)
9999
b"\xc0\x00" # common output scan direction = 0 (0 to n-1 (POR=0))
100-
b"\xa8\x01\x3f" # multiplex ratio = 64 (POR=0x7F)
100+
b"\xa8\x01\x7f" # multiplex ratio = 128 (POR=0x7F)
101101
b"\xd3\x01\x60" # set display offset mode = 0x60
102102
# b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
103103
b"\xd9\x01\x22" # pre-charge/dis-charge period mode: 2 DCLKs/2 DCLKs (POR)
@@ -132,7 +132,13 @@ def __init__(
132132
rotation=0,
133133
**kwargs
134134
):
135+
rotation = (rotation + _ROTATION_OFFSET) % 360
136+
if rotation in (0, 180):
137+
multiplex = kwargs["width"] - 1
138+
else:
139+
multiplex = kwargs["height"] - 1
135140
init_sequence = bytearray(_INIT_SEQUENCE)
141+
init_sequence[16] = multiplex
136142
init_sequence[19] = display_offset
137143
super().__init__(
138144
bus,
@@ -144,7 +150,7 @@ def __init__(
144150
data_as_commands=True, # every byte will have a command byte preceding
145151
brightness_command=0x81,
146152
single_byte_bounds=True,
147-
rotation=(rotation + _ROTATION_OFFSET) % 360,
153+
rotation=rotation,
148154
# for sh1107 use column and page addressing.
149155
# lower column command = 0x00 - 0x0F
150156
# upper column command = 0x10 - 0x17

0 commit comments

Comments
 (0)