From c4894eadad18af5c175b97025671a7d933bd7afc Mon Sep 17 00:00:00 2001 From: James Carr Date: Wed, 15 Sep 2021 09:06:02 +0100 Subject: [PATCH 1/3] Revert the multiplex ratio to 0x7F --- adafruit_displayio_sh1107.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_displayio_sh1107.py b/adafruit_displayio_sh1107.py index 34199d1..0502b84 100644 --- a/adafruit_displayio_sh1107.py +++ b/adafruit_displayio_sh1107.py @@ -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 = 64 (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) From 9a648753e6b9349981e80e51cffd2f7311308076 Mon Sep 17 00:00:00 2001 From: James Carr Date: Wed, 15 Sep 2021 09:14:48 +0100 Subject: [PATCH 2/3] Update the comment for multiplex ratio to 128 --- adafruit_displayio_sh1107.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_displayio_sh1107.py b/adafruit_displayio_sh1107.py index 0502b84..59e2c13 100644 --- a/adafruit_displayio_sh1107.py +++ b/adafruit_displayio_sh1107.py @@ -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\x7f" # 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) From d1e15a7e2a589ae34640561c807a3aeda326be1e Mon Sep 17 00:00:00 2001 From: James Carr Date: Wed, 15 Sep 2021 18:14:20 +0100 Subject: [PATCH 3/3] Auto-determine the multiplex from the width or height depending on rotation. --- adafruit_displayio_sh1107.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/adafruit_displayio_sh1107.py b/adafruit_displayio_sh1107.py index 59e2c13..2454662 100644 --- a/adafruit_displayio_sh1107.py +++ b/adafruit_displayio_sh1107.py @@ -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, @@ -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