|
3 | 3 |
|
4 | 4 | """ |
5 | 5 | This test will initialize the display using displayio and draw a solid green |
6 | | -background, a smaller purple rectangle, and some yellow text. |
| 6 | +background, a smaller purple rectangle, and some yellow text.. |
7 | 7 | """ |
8 | 8 | import board |
| 9 | +import busio |
9 | 10 | import terminalio |
10 | 11 | import displayio |
11 | 12 | from adafruit_display_text import label |
12 | 13 | from adafruit_st7789 import ST7789 |
13 | 14 |
|
14 | | -BORDER_WIDTH = 20 |
| 15 | +BORDER_WIDTH = 28 |
15 | 16 | TEXT_SCALE = 3 |
16 | 17 |
|
17 | 18 | # Release any resources currently in use for the displays |
18 | 19 | displayio.release_displays() |
19 | 20 |
|
20 | | -spi = board.SPI() |
21 | | -tft_cs = board.D5 |
22 | | -tft_dc = board.D6 |
23 | | -tft_rst = board.D9 |
| 21 | +tft_cs = board.GP5 #board.D5 |
| 22 | +tft_dc = board.GP6 #board.D6 |
| 23 | +tft_rst = board.GP7 #board.D7 |
24 | 24 |
|
| 25 | +spi = busio.SPI(board.GP2, board.GP3, board.GP4) |
25 | 26 | display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=tft_rst) |
26 | 27 |
|
27 | 28 | display = ST7789(display_bus, width=320, height=172, colstart=34, rotation=270) |
|
34 | 35 | color_palette = displayio.Palette(1) |
35 | 36 | color_palette[0] = 0x00FF00 # Bright Green |
36 | 37 | bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0) |
37 | | -splash.append(bg_sprite) |
| 38 | +splash.append(bg_sprite) |
38 | 39 |
|
39 | 40 | # Draw a smaller inner rectangle |
40 | 41 | inner_bitmap = displayio.Bitmap( |
41 | 42 | display.width - (BORDER_WIDTH * 2), display.height - (BORDER_WIDTH * 2), 1 |
42 | 43 | ) |
| 44 | + |
43 | 45 | inner_palette = displayio.Palette(1) |
44 | 46 | inner_palette[0] = 0xAA0088 # Purple |
45 | 47 | inner_sprite = displayio.TileGrid( |
|
50 | 52 | # Draw a label |
51 | 53 | text_area = label.Label( |
52 | 54 | terminalio.FONT, |
53 | | - text="Hello World!", |
| 55 | + text="Hello World!!", |
54 | 56 | color=0xFFFF00, |
55 | 57 | scale=TEXT_SCALE, |
56 | 58 | anchor_point=(0.5, 0.5), |
|
0 commit comments