Simple test
Ensure your device works with this simple test.
examples/anchored_tilegrid_simpletest.py
1# SPDX-FileCopyrightText: Copyright (c) 2024 Tim C for Adafruit Industries
2#
3# SPDX-License-Identifier: MIT
4"""
5Illustrate usage of the AnchoredTileGrid class.
6
7A speech blurb image is positioned relative to the
8point at the bottom of the blurb.
9"""
10
11import board
12from displayio import Group, OnDiskBitmap, Palette
13from vectorio import Circle
14
15from adafruit_anchored_tilegrid import AnchoredTileGrid
16
17# Reference to built-in display
18display = board.DISPLAY
19
20# palette to use for drawing a circle
21circle_palette = Palette(1)
22circle_palette[0] = 0xFF00FF
23
24# circle object, we'll place our speech blurb near this
25circle = Circle(pixel_shader=circle_palette, radius=20, x=40, y=70)
26
27# initialize a Group and add the circle to it
28main_group = Group()
29main_group.append(circle)
30
31# load the speech blurb bitmap
32speech_blurb_bmp = OnDiskBitmap("example_image.bmp")
33
34# make the background chroma key color transparent
35speech_blurb_bmp.pixel_shader.make_transparent(0)
36
37# initialize an AnchoredTileGrid for the blurb
38speech_blurb = AnchoredTileGrid(bitmap=speech_blurb_bmp, pixel_shader=speech_blurb_bmp.pixel_shader)
39
40# set the anchor point to the bottom point of the speech blurb
41speech_blurb.anchor_point = (0.18, 1.0)
42
43# position it near the circle
44speech_blurb.anchored_position = (circle.x + 16, circle.y - 16)
45
46# add it to the group
47main_group.append(speech_blurb)
48
49# set our group to root_group, so it gets shown on the display
50display.root_group = main_group
51
52
53while True:
54 # wait forever so our group stays visible
55 pass