From 256a8760ad3fde2aa82dc57339d1ec5ddc43c3c3 Mon Sep 17 00:00:00 2001 From: James Carr Date: Tue, 24 Aug 2021 15:33:48 +0100 Subject: [PATCH] Remove usage of the set_vertical_scroll Display constructor parameter. Minor docs improvements. --- README.rst | 8 ++++---- adafruit_displayio_sh1107.py | 36 +++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index ee1aa90..f4d2d53 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ Introduction :target: https://github.com/psf/black :alt: Code Style: Black -DisplayIO driver for SH1107 monochrome displays. DisplayIO drivers enable terminal output. This driver depends on a future (TBD) quirk added to DisplayIO. +DisplayIO driver for SH1107 monochrome displays. DisplayIO drivers enable terminal output. Dependencies @@ -25,11 +25,11 @@ Dependencies This driver depends on: * `Adafruit CircuitPython Version 6+ `_ A new quirk in 6.0 for SH1107 -* Adafruit SH1107 128 x 64 OLED display, used for testing. +* An SH1107 OLED display, eg. `Adafruit FeatherWing 128 x 64 OLED `_ Please ensure all dependencies are available on the CircuitPython filesystem. -This is easily achieved by downloading -`the Adafruit library and driver bundle `_. +This is easily achieved by downloading the +`Adafruit library and driver bundle `_. Installing from PyPI ===================== diff --git a/adafruit_displayio_sh1107.py b/adafruit_displayio_sh1107.py index fef9177..34199d1 100644 --- a/adafruit_displayio_sh1107.py +++ b/adafruit_displayio_sh1107.py @@ -21,7 +21,7 @@ **Software and Dependencies:** -* Adafruit CircuitPython (version 5+) firmware for the supported boards: +* Adafruit CircuitPython (version 6+) firmware for the supported boards: https://github.com/adafruit/circuitpython/releases """ @@ -37,13 +37,14 @@ DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650 = const(0x60) """ The hardware display offset to use when configuring the SH1107 for the -`Adafruit Featherwing 128x64 OLED `_ +`Adafruit Featherwing 128x64 OLED `_. +This is the default if not passed in. .. code-block:: from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650 - # Simplest constructor, assumes it is an Adafruit FeatherWing 128x64 OLED + # Constructor for the Adafruit FeatherWing 128x64 OLED display = SH1107(bus, width=128, height=64, display_offset=DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650) # Or as it's the default @@ -74,7 +75,7 @@ b"\x81\x01\x2f" # contrast setting = 0x2f b"\x21\x00" # vertical (column) addressing mode (POR=0x20) b"\xa0\x00" # segment remap = 1 (POR=0, down rotation) - b"\xcf\x00" # common output scan direction = 15 (0 to n-1 (POR=0)) + b"\xcf\x00" # common output scan direction = 15 (n-1 to 0) (POR=0) b"\xa8\x01\x7f" # multiplex ratio = 128 (POR) b"\xd3\x01\x60" # set display offset mode = 0x60 b"\xd5\x01\x51" # divide ratio/oscillator: divide by 2, fOsc (POR) @@ -91,11 +92,11 @@ _INIT_SEQUENCE = ( b"\xae\x00" # display off, sleep mode b"\xdc\x01\x00" # set display start line 0 - b"\x81\x01\x4f" # contrast setting = 0x2f + b"\x81\x01\x4f" # contrast setting = 0x4f 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 = 15 (0 to n-1 (POR=0)) - b"\xa8\x01\x3f" # multiplex ratio = 128 (POR) + b"\xc0\x00" # common output scan direction = 0 (0 to n-1 (POR=0)) + b"\xa8\x01\x3f" # 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) @@ -111,7 +112,7 @@ class SH1107(displayio.Display): """ - SSD1107 driver for use with DisplayIO + SH1107 driver for use with DisplayIO :param bus: The bus that the display is connected to. :param int width: The width of the display. Maximum of 128 @@ -139,8 +140,7 @@ def __init__( color_depth=1, grayscale=True, pixels_in_byte_share_row=_PIXELS_IN_ROW, # in vertical (column) mode - data_as_commands=True, # every byte will have a command byte preceeding - set_vertical_scroll=0xD3, # TBD -- not sure about this one! + data_as_commands=True, # every byte will have a command byte preceding brightness_command=0x81, single_byte_bounds=True, rotation=(rotation + _ROTATION_OFFSET) % 360, @@ -157,20 +157,22 @@ def is_awake(self): """ The power state of the display. (read-only) - True if the display is active, False if in sleep mode. + `True` if the display is active, `False` if in sleep mode. + + :type: bool """ return self._is_awake def sleep(self): """ - Put display into sleep mode + Put display into sleep mode. The display uses < 5uA in sleep mode - The display uses < 5uA in sleep mode Sleep mode does the following: - 1) Stops the oscillator and DC-DC circuits - 2) Stops the OLED drive - 3) Remembers display data and operation mode active prior to sleeping - 4) The MP can access (update) the built-in display RAM + + 1) Stops the oscillator and DC-DC circuits + 2) Stops the OLED drive + 3) Remembers display data and operation mode active prior to sleeping + 4) The MP can access (update) the built-in display RAM """ if self._is_awake: self.bus.send(int(0xAE), "") # 0xAE = display off, sleep mode