|
1 | 1 | """
|
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. |
6 | 5 |
|
| 6 | +Pinouts are for the 2.4" TFT FeatherWing with a Feather M4 or M0. |
| 7 | +""" |
7 | 8 | import board
|
8 | 9 | import displayio
|
| 10 | +import terminalio |
| 11 | +from adafruit_display_text import label |
9 | 12 | import adafruit_ili9341
|
10 | 13 |
|
11 | 14 | spi = board.SPI()
|
|
14 | 17 |
|
15 | 18 | displayio.release_displays()
|
16 | 19 | display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
|
17 |
| - |
18 | 20 | display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240)
|
19 | 21 |
|
20 | 22 | # Make the display context
|
21 | 23 | splash = displayio.Group(max_size=10)
|
22 | 24 | display.show(splash)
|
23 | 25 |
|
| 26 | +# Draw a green background |
24 | 27 | color_bitmap = displayio.Bitmap(320, 240, 1)
|
25 | 28 | color_palette = displayio.Palette(1)
|
26 |
| -color_palette[0] = 0xFF0000 |
| 29 | +color_palette[0] = 0x00FF00 # Bright Green |
27 | 30 |
|
28 | 31 | bg_sprite = displayio.TileGrid(color_bitmap,
|
29 | 32 | pixel_shader=color_palette,
|
30 | 33 | x=0, y=0)
|
| 34 | + |
31 | 35 | splash.append(bg_sprite)
|
32 | 36 |
|
| 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 | + |
33 | 53 | while True:
|
34 | 54 | pass
|
0 commit comments