Skip to content

Commit fbe1fbd

Browse files
Tweak the PyPortal example to specify the Font directory
1 parent 58c6644 commit fbe1fbd

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

examples/display_text_pyportal.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
from adafruit_bitmap_font import bitmap_font
1515
from adafruit_display_text.label import Label
1616

17+
FONT_DIR = "/fonts/"
1718
fonts = list(
18-
filter(lambda x: x.endswith("bdf") and not x.startswith("."), os.listdir("/"))
19+
filter(lambda x: x.endswith("bdf") and not x.startswith("."), os.listdir(FONT_DIR))
1920
)
20-
fonts = [bitmap_font.load_font(x) for x in fonts]
21+
fonts = [bitmap_font.load_font(FONT_DIR + x) for x in fonts]
22+
if len(fonts) == 0:
23+
print("No fonts found in '{}'".format(FONT_DIR))
2124

2225
print("fade up")
2326
# Fade up the backlight
@@ -30,12 +33,17 @@
3033
splash = displayio.Group()
3134
board.DISPLAY.show(splash)
3235
max_y = 0
33-
y = 2
36+
y = 0
3437
for demo_text in demos:
3538
for font in fonts:
39+
if y >= board.DISPLAY.height:
40+
y = 0
41+
while len(splash):
42+
splash.pop()
3643
print("Font load {}".format(font.name))
37-
area = Label(font, text=demo_text)
38-
area.y = y
44+
area = Label(
45+
font, text=demo_text, anchor_point=(0, 0), anchored_position=(0, y)
46+
)
3947
splash.append(area)
4048

4149
y += area.height
@@ -46,8 +54,8 @@
4654
except AttributeError:
4755
board.DISPLAY.wait_for_frame()
4856

49-
# Wait for 10 minutes (600 seconds)
50-
time.sleep(600)
57+
# Wait for 1 minute (60 seconds)
58+
time.sleep(60)
5159

5260
# Fade down the backlight
5361
for b in range(100, -1, -1):

0 commit comments

Comments
 (0)