diff --git a/README.rst b/README.rst index e45b02e..b1c67d8 100644 --- a/README.rst +++ b/README.rst @@ -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 ============ diff --git a/adafruit_displayio_sh1106.py b/adafruit_displayio_sh1106.py index 33c9c91..04fa1ff 100644 --- a/adafruit_displayio_sh1106.py +++ b/adafruit_displayio_sh1106.py @@ -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, diff --git a/docs/conf.py b/docs/conf.py index 7bb0eaa..f8a7611 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 = { diff --git a/docs/index.rst b/docs/index.rst index 36ab23c..08e1648 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 diff --git a/examples/displayio_sh1106_simpletest.py b/examples/displayio_sh1106_simpletest.py index cbcf2ce..41c2a5f 100644 --- a/examples/displayio_sh1106_simpletest.py +++ b/examples/displayio_sh1106_simpletest.py @@ -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 diff --git a/setup.py b/setup.py index bc8cb1c..0426d7c 100644 --- a/setup.py +++ b/setup.py @@ -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,