|
1 | 1 | # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
|
2 | 2 | # SPDX-FileCopyrightText: Copyright (c) 2020 Mark Roberts for Adafruit Industries
|
| 3 | +# SPDX-FileCopyrightText: 2021 James Carr |
3 | 4 | #
|
4 | 5 | # SPDX-License-Identifier: MIT
|
5 | 6 | """
|
|
9 | 10 | DisplayIO driver for SH1107 monochrome displays
|
10 | 11 |
|
11 | 12 |
|
12 |
| -* Author(s): Scott Shawcroft, Mark Roberts (mdroberts1243) |
| 13 | +* Author(s): Scott Shawcroft, Mark Roberts (mdroberts1243), James Carr |
13 | 14 |
|
14 | 15 | Implementation Notes
|
15 | 16 | --------------------
|
|
26 | 27 | """
|
27 | 28 |
|
28 | 29 | import displayio
|
| 30 | +from micropython import const |
29 | 31 |
|
30 | 32 | __version__ = "0.0.0-auto.0"
|
31 | 33 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107.git"
|
32 | 34 |
|
| 35 | + |
| 36 | +DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650 = const(0x60) |
| 37 | +""" |
| 38 | +The hardware display offset to use when configuring the SH1107 for the |
| 39 | +`Adafruit Featherwing 128x64 OLED <https://www.adafruit.com/product/4650>`_ |
| 40 | +
|
| 41 | +.. code-block:: |
| 42 | +
|
| 43 | + from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650 |
| 44 | +
|
| 45 | + # Simplest constructor, assumes it is an Adafruit FeatherWing 128x64 OLED |
| 46 | + display = SH1107(bus, width=128, height=64, |
| 47 | + display_offset=DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650) |
| 48 | + # Or as it's the default |
| 49 | + display = SH1107(bus, width=128, height=64) |
| 50 | +""" |
| 51 | + |
| 52 | +DISPLAY_OFFSET_PIMORONI_MONO_OLED_PIM374 = const(0x00) |
| 53 | +""" |
| 54 | +The hardware display offset to use when configuring the SH1107 for the |
| 55 | +`Pimoroni Mono 128x128 OLED <https://shop.pimoroni.com/products/1-12-oled-breakout>`_ |
| 56 | +
|
| 57 | +.. code-block:: |
| 58 | +
|
| 59 | + from adafruit_displayio_sh1107 import SH1107, DISPLAY_OFFSET_PIMORONI_MONO_OLED_PIM374 |
| 60 | +
|
| 61 | + # Constructor for the Pimoroni Mono 128x128 OLED |
| 62 | + display = SH1107(bus, width=128, height=128, |
| 63 | + display_offset=DISPLAY_OFFSET_PIMORONI_MONO_OLED_PIM374) |
| 64 | +""" |
| 65 | + |
| 66 | + |
33 | 67 | # Sequence from sh1107 framebuf driver formatted for displayio init
|
34 | 68 | _INIT_SEQUENCE = (
|
35 | 69 | b"\xae\x00" # display off, sleep mode
|
|
51 | 85 |
|
52 | 86 |
|
53 | 87 | class SH1107(displayio.Display):
|
54 |
| - """SSD1107 driver""" |
55 |
| - |
56 |
| - def __init__(self, bus, **kwargs): |
| 88 | + """ |
| 89 | + SSD1107 driver for use with DisplayIO |
| 90 | +
|
| 91 | + :param bus: The bus that the display is connected to. |
| 92 | + :param int width: The width of the display. Maximum of 128 |
| 93 | + :param int height: The height of the display. Maximum of 128 |
| 94 | + :param int rotation: The rotation of the display. 0, 90, 180 or 270. |
| 95 | + :param int display_offset: The display offset that the first column is wired to. |
| 96 | + This will be dependent on the OLED display and two displays with the |
| 97 | + same dimensions could have different offsets. This defaults to |
| 98 | + `DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650` |
| 99 | + """ |
| 100 | + |
| 101 | + def __init__( |
| 102 | + self, |
| 103 | + bus, |
| 104 | + display_offset=DISPLAY_OFFSET_ADAFRUIT_FEATHERWING_OLED_4650, |
| 105 | + **kwargs |
| 106 | + ): |
57 | 107 | init_sequence = bytearray(_INIT_SEQUENCE)
|
| 108 | + init_sequence[19] = display_offset |
58 | 109 | super().__init__(
|
59 | 110 | bus,
|
60 | 111 | init_sequence,
|
|
0 commit comments