Simple test
Ensure your device works with this simple test.
examples/anchored_group_simpletest.py
1# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
2#
3# SPDX-License-Identifier: Unlicense
4
5import supervisor
6import terminalio
7from adafruit_display_text.bitmap_label import Label
8from displayio import Bitmap, Group, Palette, TileGrid
9
10from adafruit_anchored_group import AnchoredGroup
11
12display = supervisor.runtime.display
13
14main_group = Group()
15
16display.root_group = main_group
17
18anchored_group = AnchoredGroup()
19
20icon_bmp = Bitmap(30, 30, 1)
21icon_palette = Palette(1)
22icon_palette[0] = 0xFF00FF
23icon_tg = TileGrid(bitmap=icon_bmp, pixel_shader=icon_palette)
24
25lbl = Label(terminalio.FONT, text="Something")
26lbl.anchor_point = (0, 0.5)
27lbl.anchored_position = (
28 icon_tg.x + (icon_tg.width * icon_tg.tile_width) + 6,
29 (icon_tg.y + (icon_tg.height * icon_tg.tile_height)) // 2,
30)
31
32
33anchored_group.append(icon_tg)
34anchored_group.append(lbl)
35print(f"group size: {anchored_group.size}")
36
37anchored_group.anchor_point = (1.0, 0)
38anchored_group.anchored_position = (display.width - 4, 0)
39
40main_group.append(anchored_group)
41
42while True:
43 pass