Skip to content
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
55 changes: 53 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,59 @@ To install in a virtual environment in your current project:
Usage Example
=============

.. todo:: Add a quick, simple example. It and other examples should live in the
examples folder and be included in docs/examples.rst.
.. code-block:: python3

import busio
import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_sh1106

displayio.release_displays()

spi = busio.SPI(board.SCK, board.MOSI)
display_bus = displayio.FourWire(
spi,
command=board.OLED_DC,
chip_select=board.OLED_CS,
reset=board.OLED_RESET,
baudrate=1000000,
)

WIDTH = 128
HEIGHT = 64
BORDER = 5
display = adafruit_displayio_sh1106.SH1106(display_bus, width=WIDTH, height=HEIGHT)

# Make the display context
splash = displayio.Group(max_size=10)
display.show(splash)

color_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF # White

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(WIDTH - BORDER * 2, HEIGHT - BORDER * 2, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000 # Black
inner_sprite = displayio.TileGrid(
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
)
splash.append(inner_sprite)

# Draw a label
text = "Hello World!"
text_area = label.Label(
terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT // 2 - 1
)
splash.append(text_area)

while True:
pass

Contributing
============
Expand Down
6 changes: 1 addition & 5 deletions adafruit_displayio_sh1106.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ class SH1106(displayio.Display):
:param int rotation: The rotation of the display. 0, 90, 180 or 270.
"""

def __init__(
self,
bus,
**kwargs
):
def __init__(self, bus, **kwargs):
init_sequence = bytearray(_INIT_SEQUENCE)
super().__init__(
bus,
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio", "busio"]
autodoc_mock_imports = ["displayio", "micropython"]


intersphinx_mapping = {
Expand Down
6 changes: 0 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ Table of Contents
.. toctree::
:caption: Tutorials

.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
the toctree above for use later.

.. toctree::
:caption: Related Products

.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
the toctree above for use later.

.. toctree::
:caption: Other Links

Expand Down
10 changes: 8 additions & 2 deletions examples/displayio_sh1106_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
import terminalio
from adafruit_display_text import label
import adafruit_displayio_sh1106

displayio.release_displays()

spi = busio.SPI(board.SCK, board.MOSI)
display_bus = displayio.FourWire(spi, command=board.OLED_DC, chip_select=board.OLED_CS,
reset=board.OLED_RESET, baudrate=1000000)
display_bus = displayio.FourWire(
spi,
command=board.OLED_DC,
chip_select=board.OLED_CS,
reset=board.OLED_RESET,
baudrate=1000000,
)

WIDTH = 128
HEIGHT = 64
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
],
# What does your project relate to?
keywords="adafruit blinka circuitpython micropython displayio_sh1106 displayio oled "
"sh1106 display",
"sh1106 display",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
Expand Down