Skip to content

Commit c3a7deb

Browse files
authored
Merge pull request #5 from makermelissa/master
Updated examples to be more comprehensive
2 parents c524357 + ea31ab1 commit c3a7deb

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

examples/st7789_320x240_simpletest.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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
"""
5-
65
import board
76
import displayio
7+
import terminalio
8+
from adafruit_display_text import label
89
from adafruit_st7789 import ST7789
910

1011
spi = board.SPI()
@@ -26,12 +27,28 @@
2627

2728
color_bitmap = displayio.Bitmap(320, 240, 1)
2829
color_palette = displayio.Palette(1)
29-
color_palette[0] = 0xFF0000
30+
color_palette[0] = 0x00FF00 # Bright Green
3031

3132
bg_sprite = displayio.TileGrid(color_bitmap,
3233
pixel_shader=color_palette,
3334
x=0, y=0)
3435
splash.append(bg_sprite)
3536

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

examples/st7789_simpletest.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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
"""
5-
65
import board
76
import displayio
7+
import terminalio
8+
from adafruit_display_text import label
89
from adafruit_st7789 import ST7789
910

1011
spi = board.SPI()
@@ -26,12 +27,28 @@
2627

2728
color_bitmap = displayio.Bitmap(240, 240, 1)
2829
color_palette = displayio.Palette(1)
29-
color_palette[0] = 0xFF0000
30+
color_palette[0] = 0x00FF00 # Bright Green
3031

3132
bg_sprite = displayio.TileGrid(color_bitmap,
3233
pixel_shader=color_palette,
3334
x=0, y=0)
3435
splash.append(bg_sprite)
3536

37+
# Draw a smaller inner rectangle
38+
inner_bitmap = displayio.Bitmap(200, 200, 1)
39+
inner_palette = displayio.Palette(1)
40+
inner_palette[0] = 0xAA0088 # Purple
41+
inner_sprite = displayio.TileGrid(inner_bitmap,
42+
pixel_shader=inner_palette,
43+
x=20, y=20)
44+
splash.append(inner_sprite)
45+
46+
# Draw a label
47+
text_group = displayio.Group(max_size=10, scale=2, x=50, y=120)
48+
text = "Hello World!"
49+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
50+
text_group.append(text_area) # Subgroup for text scaling
51+
splash.append(text_group)
52+
3653
while True:
3754
pass

0 commit comments

Comments
 (0)