adafruit_displayio_sh1107

DisplayIO driver for SH1107 monochrome displays

  • Author(s): Scott Shawcroft, Mark Roberts (mdroberts1243), James Carr

Implementation Notes

Hardware:

Software and Dependencies:

adafruit_displayio_sh1107.DISPLAY_OFFSET_ADAFRUIT_128x128_OLED_5297 = 0

The hardware display offset to use when configuring the SH1107 for the Adafruit Monochrome 1.12” 128x128 OLED.

from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_ADAFRUIT_128x128_OLED_5297

# Constructor for the Adafruit Monochrome 1.12" 128x128 OLED
display = SH1107(bus, width=128, height=128,
    display_offset=DISPLAY_OFFSET_ADAFRUIT_128x128_OLED_5297, rotation=90)
adafruit_displayio_sh1107.DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650 = 96

The hardware display offset to use when configuring the SH1107 for the Adafruit Featherwing 128x64 OLED. This is the default if not passed in.

from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650

# 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
display = SH1107(bus, width=128, height=64)
adafruit_displayio_sh1107.DISPLAY_OFFSET_PIMORONI_MONO_OLED_PIM374 = 0

The hardware display offset to use when configuring the SH1107 for the Pimoroni Mono 128x128 OLED

from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_PIMORONI_MONO_OLED_PIM374

# Constructor for the Pimoroni Mono 128x128 OLED
display = SH1107(bus, width=128, height=128,
    display_offset=DISPLAY_OFFSET_PIMORONI_MONO_OLED_PIM374)
class adafruit_displayio_sh1107.SH1107(*args, **kwargs)

SH1107 driver for use with DisplayIO

Parameters:
  • bus – The bus that the display is connected to.

  • width (int) – The width of the display. Maximum of 128

  • height (int) – The height of the display. Maximum of 128

  • rotation (int) – The rotation of the display. 0, 90, 180 or 270.

  • display_offset (int) – The display offset that the first column is wired to. This will be dependent on the OLED display and two displays with the same dimensions could have different offsets. This defaults to DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650

Create a Display object on the given display bus (fourwire.FourWire or paralleldisplaybus.ParallelBus).

The init_sequence is bitpacked to minimize the ram impact. Every command begins with a command byte followed by a byte to determine the parameter count and if a delay is need after. When the top bit of the second byte is 1, the next byte will be the delay time in milliseconds. The remaining 7 bits are the parameter count excluding any delay byte. The third through final bytes are the remaining command parameters. The next byte will begin a new command definition. Here is a portion of ILI9341 init code:

init_sequence = (
    b"\xE1\x0F\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F"
    b"\x11\x80\x78"  # Exit Sleep then delay 0x78 (120ms)
    b"\x29\x80\x78"  # Display on then delay 0x78 (120ms)
)
display = busdisplay.BusDisplay(display_bus, init_sequence, width=320, height=240)

The first command is 0xE1 with 15 (0x0F) parameters following. The second and third are 0x11 and 0x29 respectively with delays (0x80) of 120ms (0x78) and no parameters. Multiple byte literals (b”“) are merged together on load. The parens are needed to allow byte literals on subsequent lines.

The initialization sequence should always leave the display memory access inline with the scan of the display to minimize tearing artifacts.

property is_awake: bool

The power state of the display. (read-only)

True if the display is active, False if in sleep mode.

Type:

bool

sleep() None

Put display into 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

wake() None

Wake display from sleep mode