From 6bb348ac69d3e598b979c80cc04d47970bed1303 Mon Sep 17 00:00:00 2001 From: lady ada Date: Mon, 7 Jun 2021 12:35:56 -0400 Subject: [PATCH 1/4] blacken --- adafruit_displayio_sh1106.py | 6 +----- examples/displayio_sh1106_simpletest.py | 10 ++++++++-- setup.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) 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/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, From 23377954d54432c6524fb5ddcc218494d4d62372 Mon Sep 17 00:00:00 2001 From: lady ada Date: Mon, 7 Jun 2021 12:54:37 -0400 Subject: [PATCH 2/4] add mocks --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = { From b97859883630d60a57ab2643d6db3a2e87a3e3e4 Mon Sep 17 00:00:00 2001 From: lady ada Date: Mon, 7 Jun 2021 14:05:49 -0400 Subject: [PATCH 3/4] add example --- README.rst | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) 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 ============ From 8e0144e42308e401d49acaab9a47c3ca6dcfdc55 Mon Sep 17 00:00:00 2001 From: lady ada Date: Mon, 7 Jun 2021 14:09:08 -0400 Subject: [PATCH 4/4] remove todo links --- docs/index.rst | 6 ------ 1 file changed, 6 deletions(-) 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