@@ -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============
0 commit comments