~xenrox/status-display

e518c2b24a8812ee6f8e822d8878189df746642f — Thorben Günther 3 years ago 79983d9
Show weather on display
1 files changed, 21 insertions(+), 5 deletions(-)

M status-display.py
M status-display.py => status-display.py +21 -5
@@ 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()