-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (43 loc) · 1.27 KB
/
main.py
File metadata and controls
50 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
from PIL import Image, ImageDraw, ImageFont
import time
import sys
import logging
from waveshare_epd import epd7in3f
from modules import wttr, cal, slideshow
from config import Display, Paths
# Logging setup
logging.basicConfig(filename=Paths.LOG_FILE, level=logging.INFO,
format='%(asctime)s %(levelname)s: %(message)s')
# Display
epd = epd7in3f.EPD()
epd.init()
logging.info("Initializing screen")
print("Initializing screen.")
def display_image(image):
if image is None:
logging.warning("Attempted to display a None image.")
print("Attempted to display a None image")
return
epd.Clear()
epd.display(epd.getbuffer(image))
logging.info("Screen updated.")
print("Screen updated")
try:
while True:
display_image(wttr.update_weather())
time.sleep(1800)
display_image(cal.update_calendar())
time.sleep(1800)
display_image(slideshow.update_slideshow())
time.sleep(1800)
except KeyboardInterrupt:
logging.info("Interrupted by user. Putting display to sleep.")
print("Interrupted by user. Putting display to sleep.")
epd.sleep()
sys.exit()
except Exception as e:
logging.error(f"Fatal error: {e}")
print("Fatal error: {e}")
epd.sleep()
sys.exit()