|
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 | 5 |
|
6 | 6 | import board
|
7 | 7 | import displayio
|
| 8 | +import terminalio |
| 9 | +from adafruit_display_text import label |
8 | 10 | from adafruit_ssd1351 import SSD1351
|
9 | 11 |
|
10 | 12 | spi = board.SPI()
|
11 | 13 | tft_cs = board.D5
|
12 | 14 | tft_dc = board.D6
|
13 | 15 |
|
14 | 16 | displayio.release_displays()
|
15 |
| -display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9) |
| 17 | +display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, |
| 18 | + reset=board.D9, baudrate=16000000) |
16 | 19 |
|
17 | 20 | display = SSD1351(display_bus, width=128, height=128)
|
18 | 21 |
|
|
22 | 25 |
|
23 | 26 | color_bitmap = displayio.Bitmap(128, 128, 1)
|
24 | 27 | color_palette = displayio.Palette(1)
|
25 |
| -color_palette[0] = 0xFF0000 |
| 28 | +color_palette[0] = 0x00FF00 # Bright Green |
26 | 29 |
|
27 | 30 | bg_sprite = displayio.TileGrid(color_bitmap,
|
28 | 31 | pixel_shader=color_palette,
|
29 | 32 | x=0, y=0)
|
30 | 33 | splash.append(bg_sprite)
|
31 | 34 |
|
| 35 | +# Draw a smaller inner rectangle |
| 36 | +inner_bitmap = displayio.Bitmap(108, 108, 1) |
| 37 | +inner_palette = displayio.Palette(1) |
| 38 | +inner_palette[0] = 0xAA0088 # Purple |
| 39 | +inner_sprite = displayio.TileGrid(inner_bitmap, |
| 40 | + pixel_shader=inner_palette, |
| 41 | + x=10, y=10) |
| 42 | +splash.append(inner_sprite) |
| 43 | + |
| 44 | +# Draw a label |
| 45 | +text = "Hello World!" |
| 46 | +text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=30, y=64) |
| 47 | +splash.append(text_area) |
| 48 | + |
32 | 49 | while True:
|
33 | 50 | pass
|
0 commit comments