|
| 1 | +""" |
| 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 | +""" |
| 5 | + |
| 6 | +import board |
| 7 | +import displayio |
| 8 | +import terminalio |
| 9 | +from adafruit_display_text import label |
| 10 | +from adafruit_ssd1351 import SSD1351 |
| 11 | + |
| 12 | +spi = board.SPI() |
| 13 | +tft_cs = board.D5 |
| 14 | +tft_dc = board.D6 |
| 15 | + |
| 16 | +displayio.release_displays() |
| 17 | +display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, |
| 18 | + reset=board.D9, baudrate=16000000) |
| 19 | + |
| 20 | +display = SSD1351(display_bus, width=128, height=96) |
| 21 | + |
| 22 | +# Make the display context |
| 23 | +splash = displayio.Group(max_size=10) |
| 24 | +display.show(splash) |
| 25 | + |
| 26 | +color_bitmap = displayio.Bitmap(128, 96, 1) |
| 27 | +color_palette = displayio.Palette(1) |
| 28 | +color_palette[0] = 0x00FF00 # Bright Green |
| 29 | + |
| 30 | +bg_sprite = displayio.TileGrid(color_bitmap, |
| 31 | + pixel_shader=color_palette, |
| 32 | + x=0, y=0) |
| 33 | +splash.append(bg_sprite) |
| 34 | + |
| 35 | +# Draw a smaller inner rectangle |
| 36 | +inner_bitmap = displayio.Bitmap(108, 76, 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=48) |
| 47 | +splash.append(text_area) |
| 48 | + |
| 49 | +while True: |
| 50 | + pass |
0 commit comments