Skip to content

Commit 4cb5bb3

Browse files
authored
Merge pull request #2 from ladyada/main
blacken
2 parents 26f5304 + 8e0144e commit 4cb5bb3

File tree

6 files changed

+64
-17
lines changed

6 files changed

+64
-17
lines changed

README.rst

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,59 @@ To install in a virtual environment in your current project:
6666
Usage Example
6767
=============
6868

69-
.. todo:: Add a quick, simple example. It and other examples should live in the
70-
examples folder and be included in docs/examples.rst.
69+
.. code-block:: python3
70+
71+
import busio
72+
import displayio
73+
import terminalio
74+
from adafruit_display_text import label
75+
import adafruit_displayio_sh1106
76+
77+
displayio.release_displays()
78+
79+
spi = busio.SPI(board.SCK, board.MOSI)
80+
display_bus = displayio.FourWire(
81+
spi,
82+
command=board.OLED_DC,
83+
chip_select=board.OLED_CS,
84+
reset=board.OLED_RESET,
85+
baudrate=1000000,
86+
)
87+
88+
WIDTH = 128
89+
HEIGHT = 64
90+
BORDER = 5
91+
display = adafruit_displayio_sh1106.SH1106(display_bus, width=WIDTH, height=HEIGHT)
92+
93+
# Make the display context
94+
splash = displayio.Group(max_size=10)
95+
display.show(splash)
96+
97+
color_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
98+
color_palette = displayio.Palette(1)
99+
color_palette[0] = 0xFFFFFF # White
100+
101+
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
102+
splash.append(bg_sprite)
103+
104+
# Draw a smaller inner rectangle
105+
inner_bitmap = displayio.Bitmap(WIDTH - BORDER * 2, HEIGHT - BORDER * 2, 1)
106+
inner_palette = displayio.Palette(1)
107+
inner_palette[0] = 0x000000 # Black
108+
inner_sprite = displayio.TileGrid(
109+
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
110+
)
111+
splash.append(inner_sprite)
112+
113+
# Draw a label
114+
text = "Hello World!"
115+
text_area = label.Label(
116+
terminalio.FONT, text=text, color=0xFFFFFF, x=28, y=HEIGHT // 2 - 1
117+
)
118+
splash.append(text_area)
119+
120+
while True:
121+
pass
71122
72123
Contributing
73124
============

adafruit_displayio_sh1106.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ class SH1106(displayio.Display):
6161
:param int rotation: The rotation of the display. 0, 90, 180 or 270.
6262
"""
6363

64-
def __init__(
65-
self,
66-
bus,
67-
**kwargs
68-
):
64+
def __init__(self, bus, **kwargs):
6965
init_sequence = bytearray(_INIT_SEQUENCE)
7066
super().__init__(
7167
bus,

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Uncomment the below if you use native CircuitPython modules such as
2626
# digitalio, micropython and busio. List the modules you use. Without it, the
2727
# autodoc module docs will fail to generate with a warning.
28-
# autodoc_mock_imports = ["digitalio", "busio"]
28+
autodoc_mock_imports = ["displayio", "micropython"]
2929

3030

3131
intersphinx_mapping = {

docs/index.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ Table of Contents
2424
.. toctree::
2525
:caption: Tutorials
2626

27-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
28-
the toctree above for use later.
29-
3027
.. toctree::
3128
:caption: Related Products
3229

33-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
34-
the toctree above for use later.
35-
3630
.. toctree::
3731
:caption: Other Links
3832

examples/displayio_sh1106_simpletest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99
import terminalio
1010
from adafruit_display_text import label
1111
import adafruit_displayio_sh1106
12+
1213
displayio.release_displays()
1314

1415
spi = busio.SPI(board.SCK, board.MOSI)
15-
display_bus = displayio.FourWire(spi, command=board.OLED_DC, chip_select=board.OLED_CS,
16-
reset=board.OLED_RESET, baudrate=1000000)
16+
display_bus = displayio.FourWire(
17+
spi,
18+
command=board.OLED_DC,
19+
chip_select=board.OLED_CS,
20+
reset=board.OLED_RESET,
21+
baudrate=1000000,
22+
)
1723

1824
WIDTH = 128
1925
HEIGHT = 64

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
],
5454
# What does your project relate to?
5555
keywords="adafruit blinka circuitpython micropython displayio_sh1106 displayio oled "
56-
"sh1106 display",
56+
"sh1106 display",
5757
# You can just specify the packages manually here if your project is
5858
# simple. Or you can use find_packages().
5959
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,

0 commit comments

Comments
 (0)