From e518c2b24a8812ee6f8e822d8878189df746642f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Fri, 17 Jul 2020 19:32:05 +0200 Subject: [PATCH] Show weather on display --- status-display.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/status-display.py b/status-display.py index ada5f8f..c2ec7be 100644 --- a/status-display.py +++ b/status-display.py @@ -5,8 +5,10 @@ from modules.timestamp import timestamp_str from modules.weather import get_weather from PIL import Image, ImageDraw, ImageFont -font35 = ImageFont.truetype("Roboto-Bold.ttf", 35) -w_font30 = ImageFont.truetype("./weathericons-regular-webfont.ttf", 30) +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") @@ -17,14 +19,28 @@ epd.init() Himage = Image.new("1", (epd.width, epd.height), 255) draw = ImageDraw.Draw(Himage) -draw.text((520, 0), timestamp_str(), font=font35, fill=0) +# Border +draw.line((430, 0, 430, 330), fill=0, width=5) +draw.line((0, 330, 430, 330), fill=0, width=5) -icon = get_weather( +# Time +draw.text((440, 0), timestamp_str(), font=font45, fill=0) + +# Weather +current, daily = get_weather( config.get("weather", "apikey"), config.get("weather", "latitude"), config.get("weather", "longitude"), ) -draw.text((20, 0), icon, font=w_font30, fill=0) +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 buffer = epd.getbuffer(Himage) epd.clear() -- 2.44.0