Skip to content

Commit b3d1a3a

Browse files
authored
Merge pull request #4 from makermelissa/master
Updated example to be more comprehensive
2 parents 0c97655 + b150a89 commit b3d1a3a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

examples/hx8357_simpletest.py

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

66
import board
77
import displayio
8+
import terminalio
9+
from adafruit_display_text import label
810
from adafruit_hx8357 import HX8357
911

1012
spi = board.SPI()
@@ -22,12 +24,28 @@
2224

2325
color_bitmap = displayio.Bitmap(480, 320, 1)
2426
color_palette = displayio.Palette(1)
25-
color_palette[0] = 0xFF0000
27+
color_palette[0] = 0x00FF00 # Bright Green
2628

2729
bg_sprite = displayio.TileGrid(color_bitmap,
2830
pixel_shader=color_palette,
2931
x=0, y=0)
3032
splash.append(bg_sprite)
3133

34+
# Draw a smaller inner rectangle
35+
inner_bitmap = displayio.Bitmap(440, 280, 1)
36+
inner_palette = displayio.Palette(1)
37+
inner_palette[0] = 0xAA0088 # Purple
38+
inner_sprite = displayio.TileGrid(inner_bitmap,
39+
pixel_shader=inner_palette,
40+
x=20, y=20)
41+
splash.append(inner_sprite)
42+
43+
# Draw a label
44+
text_group = displayio.Group(max_size=10, scale=3, x=137, y=160)
45+
text = "Hello World!"
46+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
47+
text_group.append(text_area) # Subgroup for text scaling
48+
splash.append(text_group)
49+
3250
while True:
3351
pass

0 commit comments

Comments
 (0)