Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4"""
5This test will initialize the display using displayio and draw a solid green
6background, a smaller purple rectangle, and some yellow text.
7"""
8
9import board
10import terminalio
11import displayio
12from adafruit_display_text import label
13from adafruit_ssd1351 import SSD1351
14
15# Release any resources currently in use for the displays
16displayio.release_displays()
17
18spi = board.SPI()
19tft_cs = board.D5
20tft_dc = board.D6
21
22display_bus = displayio.FourWire(
23 spi, command=tft_dc, chip_select=tft_cs, reset=board.D9, baudrate=16000000
24)
25
26display = SSD1351(display_bus, width=128, height=128)
27
28# Make the display context
29splash = displayio.Group()
30display.root_group = splash
31
32color_bitmap = displayio.Bitmap(128, 128, 1)
33color_palette = displayio.Palette(1)
34color_palette[0] = 0x00FF00 # Bright Green
35
36bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
37splash.append(bg_sprite)
38
39# Draw a smaller inner rectangle
40inner_bitmap = displayio.Bitmap(108, 108, 1)
41inner_palette = displayio.Palette(1)
42inner_palette[0] = 0xAA0088 # Purple
43inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=10, y=10)
44splash.append(inner_sprite)
45
46# Draw a label
47text = "Hello World!"
48text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=30, y=64)
49splash.append(text_area)
50
51while True:
52 pass