Skip to content

Commit 5899438

Browse files
committed
display just the time
1 parent cc33afd commit 5899438

2 files changed

Lines changed: 26 additions & 104 deletions

File tree

PyPortal_Wakeup_Light/wake_up_light.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import busio
1111
from digitalio import DigitalInOut
1212
from analogio import AnalogIn
13-
import adafruit_adt7410
14-
13+
import displayio
14+
from adafruit_display_text.label import Label
15+
from adafruit_bitmap_font import bitmap_font
1516
from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager
1617
from adafruit_io.adafruit_io import RESTClient, AdafruitIO_RequestError
1718

18-
# thermometer graphics helper
19-
import wakeup_helper
19+
cwd = ("/"+__file__).rsplit('/', 1)[0] # the current working directory (where this file is)
2020

2121
# rate at which to refresh the pyportal screen, in seconds
2222
PYPORTAL_REFRESH = 15
@@ -47,25 +47,37 @@
4747
raise KeyError('To use this code, you need to include your Adafruit IO username \
4848
and password in a secrets.py file on the CIRCUITPY drive.')
4949

50-
# Create an instance of the Adafruit IO REST client
51-
io = RESTClient(ADAFRUIT_IO_USER, ADAFRUIT_IO_KEY, wifi)
50+
# Fonts within /fonts folder
51+
info_font = cwd+"/fonts/Nunito-Black-17.bdf"
52+
time_font = cwd+"/fonts/Nunito-Light-75.bdf"
53+
54+
# create text object group
55+
text_group = displayio.Group(max_size=6)
56+
text_group.append(text_group)
5257

53-
# Get the temperature feed from Adafruit IO
54-
temperature_feed = io.get_feed('temperature')
58+
print('loading fonts...')
59+
glyphs = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.:/ '
5560

56-
# init. graphics helper
57-
gfx = wakeup_helper.Thermometer_GFX(celsius=False)
61+
time_font = bitmap_font.load_font(time_font)
62+
time_font.load_glyphs(glyphs)
5863

59-
# init. adt7410
60-
i2c_bus = busio.I2C(board.SCL, board.SDA)
64+
# Time
65+
time_text = Label( time_font, max_glyphs=40)
66+
time_text.x = 65
67+
time_text.y = 120
68+
text_group.append(time_text)
69+
board.DISPLAY.show(time_text)
70+
71+
# Create an instance of the Adafruit IO REST client
72+
io = RESTClient(ADAFRUIT_IO_USER, ADAFRUIT_IO_KEY, wifi)
6173

6274
while True:
6375
try: # WiFi Connection
64-
# Get and display date and time form Adafruit IO
76+
# Get and display date and time from Adafruit IO
6577
print('Getting time from Adafruit IO...')
6678
datetime = io.receive_time()
6779
print('displaying time...')
68-
gfx.display_date_time(datetime)
80+
time_text.text = '%02d:%02d'%(datetime[3],datetime[4])
6981
except (ValueError, RuntimeError) as e: # WiFi Connection Failure
7082
print("Failed to get data, retrying\n", e)
7183
wifi.reset()

PyPortal_Wakeup_Light/wakeup_helper.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)