Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/multiplex' into cpython
Browse files Browse the repository at this point in the history
  • Loading branch information
lesamouraipourpre committed Sep 15, 2021
2 parents 8868384 + d1e15a7 commit 56cac7a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions adafruit_displayio_sh1107.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
b"\x20\x00" # vertical (column) addressing mode (POR=0x20)
b"\xa0\x00" # segment remap = 1 (POR=0, down rotation)
b"\xc0\x00" # common output scan direction = 0 (0 to n-1 (POR=0))
b"\xa8\x01\x3f" # multiplex ratio = 64 (POR=0x7F)
b"\xa8\x01\x7f" # multiplex ratio = 128 (POR=0x7F)
b"\xd3\x01\x60" # set display offset mode = 0x60
# b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR)
b"\xd9\x01\x22" # pre-charge/dis-charge period mode: 2 DCLKs/2 DCLKs (POR)
Expand Down Expand Up @@ -132,7 +132,13 @@ def __init__(
rotation=0,
**kwargs
):
rotation = (rotation + _ROTATION_OFFSET) % 360
if rotation in (0, 180):
multiplex = kwargs["width"] - 1
else:
multiplex = kwargs["height"] - 1
init_sequence = bytearray(_INIT_SEQUENCE)
init_sequence[16] = multiplex
init_sequence[19] = display_offset
super().__init__(
bus,
Expand All @@ -144,7 +150,7 @@ def __init__(
data_as_commands=True, # every byte will have a command byte preceding
brightness_command=0x81,
single_byte_bounds=True,
rotation=(rotation + _ROTATION_OFFSET) % 360,
rotation=rotation,
# for sh1107 use column and page addressing.
# lower column command = 0x00 - 0x0F
# upper column command = 0x10 - 0x17
Expand Down

0 comments on commit 56cac7a

Please sign in to comment.