|
36 | 36 |
|
37 | 37 | # Create two Labels to show the readings. If you have a very small
|
38 | 38 | # display you may need to change to scale=1.
|
39 |
| -display_output_label = Label(FONT, text="", scale=2) |
40 |
| -display_output_label2 = Label(FONT, text="", scale=2) |
| 39 | +date_output_label = Label(FONT, text="", scale=2) |
| 40 | +time_output_label = Label(FONT, text="", scale=2) |
41 | 41 |
|
42 | 42 | # place the label in the middle of the screen with anchored positioning
|
43 |
| -display_output_label.anchor_point = (0, 0) |
44 |
| -display_output_label.anchored_position = (4, board.DISPLAY.height // 2) |
45 |
| -display_output_label2.anchor_point = (0, 0) |
46 |
| -display_output_label2.anchored_position = (4, 10 + board.DISPLAY.height // 2) |
| 43 | +date_output_label.anchor_point = (0, 0) |
| 44 | +date_output_label.anchored_position = (4, board.DISPLAY.height // 2) |
| 45 | +time_output_label.anchor_point = (0, 0) |
| 46 | +time_output_label.anchored_position = (4, 20 + board.DISPLAY.height // 2) |
47 | 47 |
|
48 | 48 | # add the label to the main_group
|
49 |
| -main_group.append(display_output_label) |
50 |
| -main_group.append(display_output_label2) |
| 49 | +main_group.append(date_output_label) |
| 50 | +main_group.append(time_output_label) |
51 | 51 |
|
52 | 52 | # set the main_group as the root_group of the built-in DISPLAY
|
53 | 53 | board.DISPLAY.root_group = main_group
|
|
56 | 56 | while True:
|
57 | 57 | # Update the label.text property to change the text on the display
|
58 | 58 | t = rtc.datetime
|
59 |
| - display_output_label.text = ( |
| 59 | + date_output_label.text = ( |
60 | 60 | f"The date is {days[int(t.tm_wday)]} {t.tm_mday}/{t.tm_mon}/{t.tm_year}"
|
61 | 61 | )
|
62 |
| - display_output_label2.text = f"The time is {t.tm_hour}:{t.tm_min:02}:{t.tm_sec:02}" |
| 62 | + time_output_label.text = f"The time is {t.tm_hour}:{t.tm_min:02}:{t.tm_sec:02}" |
63 | 63 | # wait for a bit
|
64 | 64 | time.sleep(1)
|
0 commit comments