Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert the multiplex ratio to 0x7F #9

Merged
merged 3 commits into from
Sep 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions adafruit_displayio_sh1107.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,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 @@ -131,7 +131,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 @@ -143,7 +149,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