Skip to content

Remove usage of the set_vertical_scroll Display constructor parameter. #8

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

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ 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
=============
This driver depends on:

* `Adafruit CircuitPython Version 6+ <https://github.com/adafruit/circuitpython>`_ 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 <https://www.adafruit.com/product/4650>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_.
This is easily achieved by downloading the
`Adafruit library and driver bundle <https://circuitpython.org/libraries>`_.

Installing from PyPI
=====================
Expand Down
36 changes: 19 additions & 17 deletions adafruit_displayio_sh1107.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand All @@ -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 <https://www.adafruit.com/product/4650>`_
`Adafruit Featherwing 128x64 OLED <https://www.adafruit.com/product/4650>`_.
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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down