|
1 | 1 | """
|
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. |
4 | 4 | """
|
5 |
| - |
6 | 5 | import board
|
7 | 6 | import displayio
|
| 7 | +import terminalio |
| 8 | +from adafruit_display_text import label |
8 | 9 | from adafruit_st7789 import ST7789
|
9 | 10 |
|
10 | 11 | spi = board.SPI()
|
|
26 | 27 |
|
27 | 28 | color_bitmap = displayio.Bitmap(320, 240, 1)
|
28 | 29 | color_palette = displayio.Palette(1)
|
29 |
| -color_palette[0] = 0xFF0000 |
| 30 | +color_palette[0] = 0x00FF00 # Bright Green |
30 | 31 |
|
31 | 32 | bg_sprite = displayio.TileGrid(color_bitmap,
|
32 | 33 | pixel_shader=color_palette,
|
33 | 34 | x=0, y=0)
|
34 | 35 | splash.append(bg_sprite)
|
35 | 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] = 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 | + |
36 | 53 | while True:
|
37 | 54 | pass
|
0 commit comments