Skip to content

Commit 26d640d

Browse files
authored
Create code.py
1 parent 65e75e5 commit 26d640d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

World_Clock_Round_Display/code.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-FileCopyrightText: 2025 Ben Everard for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
'''Display a world clock on a round LCD'''
5+
6+
import board
7+
import os
8+
import displayio
9+
import fourwire
10+
from adafruit_gc9a01a import GC9A01A
11+
import time
12+
import wifi
13+
import adafruit_ntp
14+
import adafruit_connection_manager
15+
16+
wifi.radio.connect(ssid=os.getenv('CIRCUITPY_WIFI_SSID'),
17+
password=os.getenv('CIRCUITPY_WIFI_PASSWORD'))
18+
19+
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
20+
ntp = adafruit_ntp.NTP(pool, tz_offset=0, cache_seconds=3600)
21+
22+
displayio.release_displays()
23+
spi = board.SPI()
24+
tft_cs = board.TX
25+
tft_dc = board.RX
26+
27+
display_bus = fourwire.FourWire(
28+
spi, command=tft_dc, chip_select=tft_cs, reset=None
29+
)
30+
31+
display = GC9A01A(display_bus, width=240, height=240, auto_refresh=False)
32+
33+
world = displayio.OnDiskBitmap("/world.bmp")
34+
35+
tile_grid_1 = displayio.TileGrid(world, pixel_shader=world.pixel_shader)
36+
tile_grid_2 = displayio.TileGrid(world, pixel_shader=world.pixel_shader)
37+
38+
group = displayio.Group()
39+
40+
group.append(tile_grid_1)
41+
group.append(tile_grid_2)
42+
display.root_group = group
43+
44+
# Loop forever so you can enjoy your image
45+
while True:
46+
tile_grid_1.x = (20*ntp.datetime.tm_hour)+120
47+
tile_grid_2.x = tile_grid_1.x-480
48+
display.refresh()
49+
time.sleep(60)

0 commit comments

Comments
 (0)