forked from rbitting/pi-display
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
62 lines (43 loc) · 1.32 KB
/
main.py
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
51
52
53
54
55
56
57
58
59
60
61
62
import logging
from PIL import Image, ImageDraw
import utils.epd4in2 as epd4in2
from config import DISPLAY_H, DISPLAY_W
from modules.co2 import draw_co2
from modules.last_fm import draw_lastfm_info
from modules.tube import draw_tube_status
from utils.util_dates import (
get_current_date_time,
draw_last_updated,
draw_todays_date,
draw_progress_bar,
)
from utils.util_logging import set_logging_config
from modules.weather import draw_weather
set_logging_config()
try:
logging.info("********* Initializing display refresh *********")
# Init display
epd = epd4in2.EPD()
epd.init()
# Init new image to draw
Himage = Image.new("1", (DISPLAY_W, DISPLAY_H), 255)
draw = ImageDraw.Draw(Himage)
draw_todays_date(draw)
draw_weather(Himage, draw)
draw_tube_status(draw)
draw_co2(draw)
draw_lastfm_info(Himage, draw)
draw_progress_bar(draw)
last_updated = draw_last_updated(draw, DISPLAY_W)
logging.debug(last_updated)
Himage = Himage.rotate(180)
epd.display(epd.getbuffer(Himage))
logging.debug("Going to Sleep...")
epd.sleep()
logging.info("Completed refresh " + get_current_date_time())
except IOError as e:
logging.exception("IOError")
except KeyboardInterrupt:
logging.warning("ctrl + c:")
epd4in2.epdconfig.module_exit()
exit()