File tree Expand file tree Collapse file tree
CircuitPython_Display_Text/updating_text_example Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2021 Tim C, written for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+ """
5+ This examples shows how to update your label with new text.
6+ """
7+ import time
8+ import board
9+ import displayio
10+ import terminalio
11+ from adafruit_display_text import label
12+
13+ # built-in display
14+ display = board .DISPLAY
15+
16+ # Make the display context
17+ main_group = displayio .Group ()
18+ display .show (main_group )
19+
20+ # create the label
21+ updating_label = label .Label (
22+ font = terminalio .FONT ,
23+ text = "Time Is:\n {}" .format (time .monotonic ()),
24+ scale = 2
25+ )
26+
27+ # set label position on the display
28+ updating_label .anchor_point = (0 , 0 )
29+ updating_label .anchored_position = (20 , 20 )
30+
31+ # add label to group that is showing on display
32+ main_group .append (updating_label )
33+
34+ # Main loop
35+ while True :
36+
37+ # update text property to change the text showing on the display
38+ updating_label .text = "Time Is:\n {}" .format (time .monotonic ())
39+
40+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments