Skip to content

Commit 60bd71c

Browse files
committed
Updated example to be more comprehensive
1 parent 7a5753e commit 60bd71c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

examples/ssd1351_simpletest.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
"""
2-
This test will initialize the display using displayio
3-
and draw a solid red background
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
44
"""
55

66
import board
77
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
810
from adafruit_ssd1351 import SSD1351
911

1012
spi = board.SPI()
1113
tft_cs = board.D5
1214
tft_dc = board.D6
1315

1416
displayio.release_displays()
15-
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9)
17+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs,
18+
reset=board.D9, baudrate=16000000)
1619

1720
display = SSD1351(display_bus, width=128, height=128)
1821

@@ -22,12 +25,26 @@
2225

2326
color_bitmap = displayio.Bitmap(128, 128, 1)
2427
color_palette = displayio.Palette(1)
25-
color_palette[0] = 0xFF0000
28+
color_palette[0] = 0x00FF00 # Bright Green
2629

2730
bg_sprite = displayio.TileGrid(color_bitmap,
2831
pixel_shader=color_palette,
2932
x=0, y=0)
3033
splash.append(bg_sprite)
3134

35+
# Draw a smaller inner rectangle
36+
inner_bitmap = displayio.Bitmap(108, 108, 1)
37+
inner_palette = displayio.Palette(1)
38+
inner_palette[0] = 0xAA0088 # Purple
39+
inner_sprite = displayio.TileGrid(inner_bitmap,
40+
pixel_shader=inner_palette,
41+
x=10, y=10)
42+
splash.append(inner_sprite)
43+
44+
# Draw a label
45+
text = "Hello World!"
46+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=30, y=64)
47+
splash.append(text_area)
48+
3249
while True:
3350
pass

0 commit comments

Comments
 (0)