Skip to content

Commit ee77dac

Browse files
committed
Examples: Replace individual icons with a material symbols font.
1 parent 77c184c commit ee77dac

13 files changed

+45
-72
lines changed
41.8 KB
Binary file not shown.

examples/attitude_indicator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(-4.5, 16.82), (-9.92, 6.75), (-19.99, 1.33), (-16.1, -2.5), (-8.17, -1.13), (-2.58, -6.71), (-19.93, -14.1), (-15.33, -18.8), (5.73, -15.08), (12.52, -21.87), (13.6, -22.66), (15.25, -23.11), (16.46, -23.05), (17.73, -22.63), (19.14, -21.42), (19.62, -20.63), (19.97, -19.45), (19.99, -18.25), (19.79, -17.33), (19.32, -16.37), (18.79, -15.72), (11.92, -8.84), (15.64, 12.17), (10.99, 16.82), (3.54, -0.53), (-2.04, 5.05), (-0.61, 12.93), (-4.5, 16.82)]]
1+
# ICON travel
22
# NAME Attitude Indicator
33
# DESC A Demo for the Multi-Sensor Stick
44
import machine

examples/awesome_game.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(-6.09, 20.0), (-7.14, 19.96), (-8.63, 19.78), (-10.29, 19.37), (-11.02, 19.11), (-12.48, 18.43), (-14.22, 17.27), (-15.52, 16.12), (-16.4, 15.14), (-17.1, 14.22), (-18.16, 12.38), (-18.65, 11.2), (-19.11, 9.61), (-19.36, 7.97), (-19.42, 6.62), (-19.38, 5.51), (-19.18, 3.92), (-18.88, 2.66), (-18.41, 1.33), (-17.67, -0.14), (-16.69, -1.58), (-15.84, -2.55), (-14.4, -3.87), (-13.45, -4.56), (-12.16, -5.31), (-10.14, -6.11), (-9.01, -6.39), (-7.41, -6.62), (-5.64, -6.67), (-4.29, -8.95), (-3.72, -9.57), (-3.13, -9.89), (-1.99, -10.1), (-0.79, -9.76), (0.58, -8.98), (1.09, -9.81), (2.19, -10.97), (3.05, -11.48), (4.52, -11.93), (5.79, -12.0), (6.89, -11.81), (7.63, -11.53), (9.64, -10.4), (7.87, -7.33), (6.31, -8.22), (5.76, -8.42), (4.89, -8.34), (4.09, -7.86), (3.64, -7.2), (5.42, -6.18), (6.24, -5.44), (6.6, -4.67), (6.71, -3.51), (6.42, -2.62), (5.2, -0.44), (5.84, 0.67), (6.61, 2.64), (6.97, 4.01), (7.21, 5.68), (7.24, 6.93), (7.07, 8.92), (6.58, 10.95), (6.05, 12.29), (5.46, 13.42), (4.79, 14.43), (3.52, 15.94), (1.73, 17.51), (0.37, 18.39), (-1.78, 19.33), (-3.76, 19.82), (-6.04, 20.0)], [(-6.09, 16.44), (-4.82, 16.37), (-3.91, 16.22), (-2.71, 15.87), (-1.8, 15.49), (-0.58, 14.77), (0.12, 14.22), (1.31, 13.05), (1.98, 12.2), (2.87, 10.64), (3.33, 9.36), (3.66, 7.41), (3.63, 5.64), (3.46, 4.6), (3.06, 3.23), (2.2, 1.46), (1.02, -0.4), (2.89, -3.6), (-1.73, -6.27), (-3.6, -3.07), (-5.56, -3.07), (-6.96, -2.99), (-8.83, -2.61), (-10.73, -1.84), (-12.3, -0.84), (-13.31, 0.04), (-14.04, 0.85), (-14.84, 2.07), (-15.34, 3.18), (-15.77, 4.78), (-15.9, 6.13), (-15.8, 8.14), (-15.36, 9.93), (-14.76, 11.29), (-14.07, 12.38), (-13.1, 13.52), (-12.35, 14.21), (-10.96, 15.18), (-9.77, 15.76), (-8.63, 16.13), (-7.05, 16.4), (-6.13, 16.44)], [(14.09, -4.89), (14.09, -8.44), (19.42, -8.44), (19.42, -4.89), (14.09, -4.89)], [(4.31, -14.67), (4.31, -20.0), (7.87, -20.0), (7.87, -14.67), (4.31, -14.67)], [(12.98, -11.07), (10.49, -13.56), (14.27, -17.33), (16.76, -14.84), (12.98, -11.07)]]
1+
# ICON bomb
22
# NAME Awesome Game
33
# DESC tufty2040 port of awesome_game.py
44
"""

examples/cheerlights_bulb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(0.0, 24.0), (-1.93, 23.66), (-3.75, 22.51), (-4.42, 21.69), (-5.11, 20.23), (-5.33, 18.73), (5.33, 18.67), (4.91, 20.77), (4.06, 22.12), (3.34, 22.82), (2.1, 23.58), (0.07, 24.0)], [(-10.67, 16.0), (-10.67, 10.67), (10.67, 10.67), (10.67, 16.0), (-10.67, 16.0)], [(-10.0, 8.0), (-12.44, 6.31), (-15.06, 3.8), (-16.01, 2.64), (-17.3, 0.72), (-18.55, -1.82), (-19.23, -3.78), (-19.81, -6.5), (-20.0, -9.27), (-19.89, -11.51), (-19.37, -14.52), (-18.51, -17.1), (-17.78, -18.66), (-16.29, -21.03), (-14.06, -23.61), (-12.39, -25.08), (-10.53, -26.4), (-8.18, -27.66), (-6.51, -28.31), (-4.11, -28.95), (-2.22, -29.22), (0.14, -29.33), (1.92, -29.25), (4.76, -28.8), (6.5, -28.31), (8.89, -27.32), (10.67, -26.3), (12.4, -25.04), (13.76, -23.84), (15.55, -21.92), (17.31, -19.45), (18.36, -17.41), (18.97, -15.86), (19.6, -13.52), (19.94, -11.05), (20.0, -9.2), (19.79, -6.43), (19.48, -4.78), (18.72, -2.32), (17.93, -0.54), (16.56, 1.79), (15.4, 3.37), (13.36, 5.52), (11.65, 6.91), (10.06, 7.97), (-10.0, 8.0)], [(-8.4, 2.67), (8.4, 2.67), (10.02, 1.35), (10.94, 0.41), (12.14, -1.14), (13.64, -3.98), (14.23, -5.77), (14.51, -7.17), (14.67, -9.27), (14.51, -11.57), (14.19, -13.19), (13.44, -15.35), (12.77, -16.67), (11.72, -18.23), (10.81, -19.31), (9.38, -20.66), (7.64, -21.92), (6.27, -22.66), (4.72, -23.28), (2.72, -23.77), (0.53, -23.99), (-1.72, -23.91), (-3.36, -23.64), (-5.45, -23.01), (-7.77, -21.85), (-9.2, -20.82), (-10.81, -19.3), (-11.81, -18.11), (-12.99, -16.27), (-13.5, -15.21), (-14.28, -12.86), (-14.62, -10.59), (-14.65, -8.58), (-14.21, -5.65), (-13.82, -4.34), (-13.1, -2.66), (-11.6, -0.36), (-10.56, 0.82), (-8.45, 2.63)], [(0.0, 2.67), (0.0, 2.67)]]
1+
# ICON lightbulb
22
# NAME Bulb
33
# DESC A cheerlight connected desk light.
44

examples/cubes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(-2.22, 14.25), (-2.22, -0.97), (-15.56, -8.69), (-15.56, 6.53), (-2.22, 14.25)], [(2.22, 14.25), (15.56, 6.53), (15.56, -8.69), (2.22, -0.97), (2.22, 14.25)], [(0.0, -4.8), (13.17, -12.41), (0.0, -20.02), (-13.17, -12.41), (0.0, -4.8)], [(-17.78, 10.42), (-18.66, 9.77), (-19.42, 8.86), (-19.9, 7.58), (-20.0, 6.64), (-20.0, -11.08), (-19.9, -12.09), (-19.47, -13.25), (-18.77, -14.15), (-17.83, -14.88), (-2.22, -23.86), (-0.66, -24.42), (0.61, -24.42), (2.17, -23.89), (17.78, -14.91), (19.13, -13.71), (19.81, -12.36), (20.0, -11.13), (20.0, 6.59), (19.87, 7.68), (19.3, 8.95), (18.5, 9.91), (17.83, 10.39), (2.22, 19.37), (1.51, 19.7), (0.06, 19.98), (-1.15, 19.82), (-2.17, 19.39), (-17.78, 10.42)], [(0.0, -2.25), (0.0, -2.25)]]
1+
# ICON deployed-code
22
# NAME Flying Cubes
33
# DESC Cubes that are flying!
44

examples/image_gallery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(-6.0, 2.0), (14.0, 2.0), (7.1, -7.0), (2.5, -1.0), (-0.6, -5.0), (-6.0, 2.0)], [(-8.0, 10.0), (-8.77, 9.93), (-10.0, 9.49), (-10.81, 8.88), (-11.53, 7.91), (-11.87, 7.04), (-12.0, 6.05), (-12.0, -18.0), (-11.72, -19.5), (-11.15, -20.47), (-10.47, -21.14), (-9.78, -21.58), (-8.86, -21.91), (-8.05, -22.0), (16.0, -22.0), (16.82, -21.92), (18.02, -21.44), (18.51, -21.07), (19.42, -20.05), (19.83, -19.17), (20.0, -18.05), (20.0, 6.0), (19.7, 7.54), (19.37, 8.16), (18.65, 8.99), (17.36, 9.77), (16.05, 10.0), (-8.0, 10.0)], [(-8.0, 6.0), (16.0, 6.0), (16.0, -18.0), (-8.0, -18.0), (-8.0, 6.0)], [(-16.0, 18.0), (-16.73, 17.94), (-17.83, 17.58), (-18.81, 16.88), (-19.26, 16.35), (-19.79, 15.31), (-20.0, 14.05), (-20.0, -14.0), (-16.0, -14.0), (-16.0, 14.0), (12.0, 14.0), (12.0, 18.0), (-16.0, 18.0)], [(-8.0, -18.0), (-8.0, -18.0)]]
1+
# ICON photo-library
22
# NAME Photo Frame
33
# DESC A touch enabled image gallery
44

examples/main.py

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@
2626

2727
WIDTH, HEIGHT = display.get_bounds()
2828

29+
icons = {
30+
"travel": "\ue6ca",
31+
"bomb": "\uf568",
32+
"lightbulb": "\ue0f0",
33+
"deployed-code": "\uf720",
34+
"photo-library": "\ue413",
35+
"joystick": "\uf5ee",
36+
"monitoring": "\uf190",
37+
"timer": "\ue425",
38+
"description": "\ue873",
39+
"schedule": "\ue8b5"
40+
}
41+
2942
CENTER_Y = HEIGHT // 2
3043
CENTER_X = WIDTH // 2
3144

@@ -47,8 +60,11 @@
4760
# Pico Vector
4861
vector = PicoVector(display)
4962
vector.set_antialiasing(ANTIALIAS_FAST)
50-
vector.set_font("Roboto-Medium.af", 10)
63+
64+
vector.set_font("Roboto-Medium-With-Material-Symbols.af", 20)
5165
vector.set_font_align(HALIGN_CENTER)
66+
67+
5268
t = Transform()
5369

5470
# Touch tracking and menu movement
@@ -67,45 +83,6 @@
6783

6884

6985
class Application:
70-
DEFAULT_ICON = [
71-
[(-10.0, 12.5), (10.0, 12.5), (10.0, 7.5), (-10.0, 7.5), (-10.0, 12.5)],
72-
[(-10.0, 2.5), (10.0, 2.5), (10.0, -2.5), (-10.0, -2.5), (-10.0, 2.5)],
73-
[
74-
(-15.0, 22.5),
75-
(-16.43, 22.31),
76-
(-17.75, 21.71),
77-
(-18.52, 21.11),
78-
(-19.47, 19.78),
79-
(-19.92, 18.46),
80-
(-20.0, 17.56),
81-
(-20.0, -22.5),
82-
(-19.77, -24.05),
83-
(-18.82, -25.73),
84-
(-17.79, -26.64),
85-
(-16.69, -27.21),
86-
(-15.06, -27.5),
87-
(5.0, -27.5),
88-
(20.0, -12.5),
89-
(20.0, 17.5),
90-
(19.77, 19.04),
91-
(19.36, 19.95),
92-
(18.55, 21.02),
93-
(17.74, 21.68),
94-
(16.7, 22.21),
95-
(15.06, 22.5),
96-
(-15.0, 22.5),
97-
],
98-
[
99-
(2.5, -10.0),
100-
(2.5, -22.5),
101-
(-15.0, -22.5),
102-
(-15.0, 17.5),
103-
(15.0, 17.5),
104-
(15.0, -10.0),
105-
(2.5, -10.0),
106-
]
107-
]
108-
10986
maximum_scale = 1.6
11087
minimum_scale = 0.6
11188
count = 0
@@ -115,7 +92,7 @@ def __init__(self, w, h, file):
11592
Application.count += 1
11693

11794
self.selected = False
118-
self.icon = Polygon()
95+
self.icon = "description"
11996

12097
# Bit of filename formatting for scripts without a title in the header.
12198
self.name = " ".join([w[0].upper() + w[1:] for w in file[:-3].replace("_", " ").split()])
@@ -126,15 +103,8 @@ def __init__(self, w, h, file):
126103

127104
for line in header:
128105
if line.startswith("# ICON "):
129-
try:
130-
for path in eval(line[7:]):
131-
self.icon.path(*path)
132-
except: # noqa: E722 - eval could barf up all kinds of nonsense
133-
pass
134-
else:
135-
# If there's no icon in the file header we'll use the default.
136-
for path in self.DEFAULT_ICON:
137-
self.icon.path(*path)
106+
icon = line[7:].strip()
107+
self.icon = icons[icon]
138108

139109
if line.startswith("# NAME "):
140110
self.name = line[7:]
@@ -206,12 +176,13 @@ def update(self, move_angle):
206176
self.t.scale(self.scale, self.scale)
207177

208178
def draw(self, selected=False):
179+
vector.set_font_size(20)
209180
display.set_pen(self.color_bg)
210181
vector.set_transform(self.t)
211182
vector.draw(self.bg)
212183
display.set_pen(self.color_fg)
213184
self.t.translate(0, 2)
214-
vector.draw(self.icon)
185+
vector.text(self.icon, 0, 0)
215186

216187
if selected:
217188
self.t.translate(0, -2)

examples/random_maze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(-11.56, 1.11), (0.0, 7.78), (11.56, 1.11), (2.22, -4.28), (2.22, 3.33), (-2.22, 3.33), (-2.22, -4.28), (-11.56, 1.11)], [(-2.22, -9.39), (-2.22, -10.34), (-3.3, -10.74), (-4.64, -11.51), (-5.8, -12.55), (-6.44, -13.37), (-7.24, -14.88), (-7.71, -16.74), (-7.72, -18.72), (-7.48, -19.97), (-6.64, -21.86), (-5.73, -23.04), (-5.01, -23.73), (-3.61, -24.69), (-1.71, -25.38), (-0.28, -25.55), (1.62, -25.39), (3.12, -24.93), (3.95, -24.5), (5.46, -23.32), (6.53, -22.02), (7.05, -21.11), (7.52, -19.84), (7.78, -17.89), (7.58, -15.97), (6.93, -14.19), (6.25, -13.1), (5.17, -11.94), (4.14, -11.19), (2.28, -10.35), (2.22, -9.39), (17.78, -0.45), (18.8, 0.37), (19.28, 1.03), (19.88, 2.42), (20.0, 3.39), (20.0, 7.66), (19.68, 9.34), (19.09, 10.4), (17.83, 11.52), (2.22, 20.5), (0.49, 21.08), (-0.5, 21.08), (-2.17, 20.53), (-17.78, 11.55), (-18.42, 11.11), (-19.42, 9.99), (-19.91, 8.59), (-20.0, 7.72), (-20.0, 3.44), (-19.95, 2.71), (-19.47, 1.27), (-18.95, 0.53), (-17.83, -0.42), (-2.22, -9.39)], [(-2.22, 11.61), (-15.56, 3.94), (-15.56, 7.66), (0.0, 16.66), (15.56, 7.66), (15.56, 3.94), (2.22, 11.61), (0.98, 12.11), (0.06, 12.22), (-1.26, 12.03), (-2.17, 11.64)], [(0.0, -14.45), (1.16, -14.64), (1.89, -15.01), (2.52, -15.6), (3.12, -16.6), (3.33, -17.73), (3.23, -18.6), (2.76, -19.63), (1.79, -20.58), (0.43, -21.09), (-0.91, -20.99), (-1.63, -20.69), (-2.61, -19.87), (-3.22, -18.68), (-3.33, -17.84), (-3.18, -16.75), (-2.43, -15.43), (-1.73, -14.9), (-0.75, -14.52), (-0.06, -14.45)], [(0.0, 16.66), (0.0, 16.66)]]
1+
# ICON joystick
22
# NAME Random Maze
33
# DESC Escape the randomly generated mazes!
44

examples/sensor-stick-temperature.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# ICON [[(-20.0, 16.67), (-20.0, 12.22), (-15.56, 7.78), (-15.56, 16.67), (-20.0, 16.67)], [(-11.11, 16.67), (-11.11, 3.33), (-6.67, -1.11), (-6.67, 16.67), (-11.11, 16.67)], [(-2.22, 16.67), (-2.22, -1.11), (2.22, 3.39), (2.22, 16.67), (-2.22, 16.67)], [(6.67, 16.67), (6.67, 3.39), (11.11, -1.06), (11.11, 16.67), (6.67, 16.67)], [(15.56, 16.67), (15.56, -5.56), (20.0, -10.0), (20.0, 16.67), (15.56, 16.67)], [(-20.0, 5.17), (-20.0, -1.11), (-4.44, -16.67), (4.44, -7.78), (20.0, -23.33), (20.0, -17.06), (4.44, -1.5), (-4.44, -10.39), (-20.0, 5.17)]]
1+
# ICON monitoring
22
# NAME Temperature
33
# DESC Display data from your Multi Sensor Stick!
44

5-
import machine
5+
from presto import Presto
66
from breakout_bme280 import BreakoutBME280
77
from picovector import ANTIALIAS_BEST, PicoVector, Polygon, Transform
8-
from presto import Presto
8+
import machine
99

1010
# Setup for the Presto display
1111
presto = Presto(ambient_light=True)

examples/stop_watch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ICON [[(-6.68, -21.11), (-6.68, -25.56), (6.65, -25.56), (6.65, -21.11), (-6.68, -21.11)], [(-2.24, 3.33), (2.21, 3.33), (2.21, -10.0), (-2.24, -10.0), (-2.24, 3.33)], [(-0.01, 21.11), (-1.81, 21.04), (-4.31, 20.66), (-6.31, 20.12), (-7.74, 19.58), (-9.01, 18.96), (-11.19, 17.66), (-13.09, 16.19), (-14.09, 15.26), (-15.63, 13.54), (-16.45, 12.45), (-17.69, 10.44), (-18.44, 8.94), (-19.27, 6.56), (-19.81, 4.04), (-19.98, 2.23), (-19.96, -0.37), (-19.74, -2.24), (-19.26, -4.37), (-18.84, -5.66), (-18.07, -7.44), (-17.05, -9.29), (-15.94, -10.92), (-14.5, -12.61), (-12.53, -14.43), (-11.26, -15.37), (-8.95, -16.74), (-7.69, -17.32), (-5.89, -17.99), (-4.53, -18.37), (-2.66, -18.71), (0.04, -18.89), (1.4, -18.84), (3.65, -18.56), (6.55, -17.8), (8.48, -17.01), (10.52, -15.93), (12.5, -14.59), (15.65, -17.67), (18.76, -14.56), (15.65, -11.44), (16.86, -9.69), (17.83, -7.96), (18.93, -5.34), (19.54, -3.11), (19.83, -1.43), (19.98, 0.78), (19.94, 2.46), (19.72, 4.37), (19.45, 5.71), (18.93, 7.47), (17.98, 9.76), (17.27, 11.08), (16.21, 12.74), (15.1, 14.15), (13.38, 15.9), (11.77, 17.21), (10.65, 17.99), (8.92, 18.98), (6.84, 19.9), (5.13, 20.45), (3.04, 20.88), (0.04, 21.11)], [(-0.01, 16.67), (2.64, 16.46), (4.57, 16.02), (6.73, 15.18), (8.41, 14.23), (9.35, 13.55), (11.26, 11.83), (12.39, 10.51), (13.25, 9.3), (14.08, 7.8), (14.79, 6.03), (15.25, 4.22), (15.54, 1.33), (15.39, -1.12), (14.81, -3.73), (14.22, -5.27), (13.69, -6.34), (12.58, -8.05), (11.48, -9.37), (10.3, -10.53), (8.13, -12.18), (6.44, -13.09), (4.91, -13.69), (2.83, -14.2), (1.19, -14.4), (-0.74, -14.43), (-2.3, -14.29), (-4.61, -13.79), (-7.19, -12.74), (-9.09, -11.55), (-11.13, -9.77), (-12.29, -8.46), (-13.7, -6.36), (-14.42, -4.87), (-15.1, -2.81), (-15.42, -1.16), (-15.57, 1.11), (-15.42, 3.35), (-14.88, 5.81), (-13.86, 8.28), (-12.89, 9.89), (-11.05, 12.07), (-9.71, 13.29), (-8.51, 14.17), (-6.09, 15.48), (-4.09, 16.16), (-2.86, 16.43), (-0.07, 16.67)], [(-0.01, 1.11)]]
1+
# ICON timer
22
# NAME Stopwatch
33
# DESC A simple stopwatch timer
44

0 commit comments

Comments
 (0)