Skip to content

Commit dd68742

Browse files
authored
Merge pull request #9 from makermelissa/master
Updated examples to include more drawing
2 parents ee73323 + dff278a commit dd68742

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

examples/ili9341_shield_simpletest.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""
2-
This test will initialize the display using displayio
3-
and draw a solid red background. Pinouts are for the 2.8"
4-
TFT Shield
5-
"""
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text.
64
5+
Pinouts are for the 2.8" TFT Shield
6+
"""
77
import board
88
import displayio
9+
import terminalio
10+
from adafruit_display_text import label
911
import adafruit_ili9341
1012

1113
spi = board.SPI()
@@ -14,21 +16,38 @@
1416

1517
displayio.release_displays()
1618
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
17-
1819
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
1920

2021
# Make the display context
2122
splash = displayio.Group(max_size=10)
2223
display.show(splash)
2324

25+
# Draw a green background
2426
color_bitmap = displayio.Bitmap(320, 240, 1)
2527
color_palette = displayio.Palette(1)
26-
color_palette[0] = 0xFF0000
28+
color_palette[0] = 0x00FF00 # Bright Green
2729

2830
bg_sprite = displayio.TileGrid(color_bitmap,
2931
pixel_shader=color_palette,
3032
x=0, y=0)
33+
3134
splash.append(bg_sprite)
3235

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

examples/ili9341_simpletest.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""
2-
This test will initialize the display using displayio
3-
and draw a solid red background. The default pinouts are
4-
for the 2.4" TFT FeatherWing with a Feather M4 or M0.
5-
"""
2+
This test will initialize the display using displayio and draw a solid green
3+
background, a smaller purple rectangle, and some yellow text. All drawing is done
4+
using native displayio modules.
65
6+
Pinouts are for the 2.4" TFT FeatherWing with a Feather M4 or M0.
7+
"""
78
import board
89
import displayio
10+
import terminalio
11+
from adafruit_display_text import label
912
import adafruit_ili9341
1013

1114
spi = board.SPI()
@@ -14,21 +17,38 @@
1417

1518
displayio.release_displays()
1619
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
17-
1820
display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
1921

2022
# Make the display context
2123
splash = displayio.Group(max_size=10)
2224
display.show(splash)
2325

26+
# Draw a green background
2427
color_bitmap = displayio.Bitmap(320, 240, 1)
2528
color_palette = displayio.Palette(1)
26-
color_palette[0] = 0xFF0000
29+
color_palette[0] = 0x00FF00 # Bright Green
2730

2831
bg_sprite = displayio.TileGrid(color_bitmap,
2932
pixel_shader=color_palette,
3033
x=0, y=0)
34+
3135
splash.append(bg_sprite)
3236

37+
# Draw a smaller inner rectangle
38+
inner_bitmap = displayio.Bitmap(280, 200, 1)
39+
inner_palette = displayio.Palette(1)
40+
inner_palette[0] = 0x65328F # Blinka 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 gor text scaling
51+
splash.append(text_group)
52+
3353
while True:
3454
pass

0 commit comments

Comments
 (0)