|
1 | 1 | """
|
2 | 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. |
| 3 | +background, a smaller purple rectangle, and some yellow text. |
5 | 4 |
|
6 | 5 | Pinouts are for the 2.8" TFT Shield
|
7 | 6 | """
|
8 | 7 | import board
|
9 | 8 | import displayio
|
10 | 9 | import terminalio
|
| 10 | +from adafruit_display_text import label |
11 | 11 | import adafruit_ili9341
|
12 | 12 |
|
13 | 13 | spi = board.SPI()
|
|
42 | 42 | x=20, y=20)
|
43 | 43 | splash.append(inner_sprite)
|
44 | 44 |
|
45 |
| -# Draw some text the manual way! |
46 |
| -font_palette = displayio.Palette(2) |
47 |
| -font_palette.make_transparent(0) |
48 |
| -font_palette[1] = 0xFFFF00 # Yellow |
49 |
| - |
50 |
| -text_group = displayio.Group(max_size=20, scale=3, x=57, y=120) |
| 45 | +# Draw a label |
| 46 | +text_group = displayio.Group(max_size=10, scale=3, x=57, y=120) |
51 | 47 | text = "Hello World!"
|
52 |
| -x = 0 |
53 |
| - |
54 |
| -for character in text: |
55 |
| - glyph = terminalio.FONT.get_glyph(ord(character)) |
56 |
| - position_x = x + glyph.dx |
57 |
| - position_y = 0 - round((glyph.height - glyph.dy) / 2) # Center text vertically |
58 |
| - face = displayio.TileGrid(glyph.bitmap, pixel_shader=font_palette, |
59 |
| - default_tile=glyph.tile_index, |
60 |
| - tile_width=glyph.width, tile_height=glyph.height, |
61 |
| - x=position_x, y=position_y) |
62 |
| - text_group.append(face) |
63 |
| - x += glyph.shift_x |
64 |
| - |
| 48 | +text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00) |
| 49 | +text_group.append(text_area) # Subgroup gor text scaling |
65 | 50 | splash.append(text_group)
|
66 | 51 |
|
67 | 52 | while True:
|
|
0 commit comments