import configparser import driver as epd from modules.mail import get_unread from modules.server import is_up from modules.timestamp import timestamp_str from modules.weather import get_weather from PIL import Image, ImageDraw, ImageFont font45 = ImageFont.truetype("Roboto-Bold.ttf", 45) font90 = ImageFont.truetype("Roboto-Bold.ttf", 90) w_font45 = ImageFont.truetype("./weathericons-regular-webfont.ttf", 45) w_font80 = ImageFont.truetype("./weathericons-regular-webfont.ttf", 80) config = configparser.ConfigParser() config.read("config.ini") epd = epd.EPD() epd.init() Himage = Image.new("1", (epd.width, epd.height), 255) draw = ImageDraw.Draw(Himage) # Border draw.line((430, 0, 430, 330), fill=0, width=5) draw.line((0, 330, 430, 330), fill=0, width=5) # Weather current, daily = get_weather( config.get("weather", "apikey"), config.get("weather", "latitude"), config.get("weather", "longitude"), ) draw.text((30, 0), current[0], font=w_font80, fill=0) draw.text((180, 0), "{}°C".format(current[1]), font=font90, fill=0) y = 130 for i in range(len(daily)): draw.text((30, y), daily[i][0], font=font45, fill=0) draw.text((130, y - 5), daily[i][3], font=w_font45, fill=0) draw.text((220, y), "{} | {}".format(daily[i][1], daily[i][2]), font=font45, fill=0) y += 70 # Server status server = config._sections["server"] for name in server: draw.text((30, y), "{}: {}".format(name, is_up(server[name])), font=font45, fill=0) y += 70 y = 0 # Time draw.text((440, y), timestamp_str(), font=font45, fill=0) y = +70 # Unread mails draw.text( (440, y), "Mail: {}".format( get_unread( config.get("mail", "ip"), config.get("mail", "port"), config.get("mail", "user"), config.get("mail", "password"), ) ), font=font45, fill=0, ) buffer = epd.getbuffer(Himage) epd.clear() epd.display(buffer) epd.sleep()