Skip to content

Commit 89378aa

Browse files
committed
adding magtag simpletest
1 parent 188341f commit 89378aa

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""
2+
Simpletest example adapted for use on the MagTag
3+
"""
4+
import board
5+
import displayio
6+
from adafruit_display_shapes.rect import Rect
7+
from adafruit_display_shapes.circle import Circle
8+
from adafruit_display_shapes.roundrect import RoundRect
9+
from adafruit_display_shapes.triangle import Triangle
10+
from adafruit_display_shapes.line import Line
11+
from adafruit_display_shapes.polygon import Polygon
12+
13+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
14+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
15+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
16+
display = board.DISPLAY
17+
18+
# Make the display context
19+
splash = displayio.Group(max_size=20)
20+
display.show(splash)
21+
22+
# Make a background color fill
23+
color_bitmap = displayio.Bitmap(display.width, display.height, 1)
24+
color_palette = displayio.Palette(1)
25+
color_palette[0] = 0xFFFFFF
26+
bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette)
27+
splash.append(bg_sprite)
28+
##########################################################################
29+
30+
splash.append(Line(5, 74, 10, 110, 0x000000))
31+
splash.append(Line(15, 74, 20, 110, 0x000000))
32+
splash.append(Line(25, 74, 30, 110, 0x000000))
33+
splash.append(Line(35, 74, 40, 110, 0x000000))
34+
35+
# Draw star
36+
polygon = Polygon(
37+
[
38+
(255, 40),
39+
(262, 62),
40+
(285, 62),
41+
(265, 76),
42+
(275, 100),
43+
(255, 84),
44+
(235, 100),
45+
(245, 76),
46+
(225, 62),
47+
(248, 62),
48+
],
49+
outline=0x000000,
50+
)
51+
splash.append(polygon)
52+
53+
triangle = Triangle(170, 20, 140, 90, 210, 100, fill=0xFFFFFF, outline=0x000000)
54+
splash.append(triangle)
55+
56+
rect = Rect(80, 20, 41, 41, fill=0x0)
57+
splash.append(rect)
58+
59+
circle = Circle(100, 100, 20, fill=0xFFFFFF, outline=0x000000)
60+
splash.append(circle)
61+
62+
rect2 = Rect(70, 85, 61, 30, outline=0x0, stroke=3)
63+
splash.append(rect2)
64+
65+
roundrect = RoundRect(10, 10, 61, 51, 10, fill=0x000000, outline=0x000000, stroke=6)
66+
splash.append(roundrect)
67+
68+
display.refresh()
69+
while True:
70+
pass

0 commit comments

Comments
 (0)