Added icons and changed the printing image method

master
José Carlos Cuevas 4 years ago
parent c57f169555
commit 38c96235e8

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -2,9 +2,8 @@
# python imports
import logging
import sys
import datetime
import random
import os.path
# 3rd party imports
import requests
@ -43,7 +42,7 @@ def reset_defaults(printer):
"""
Reset the printer to the defaults
"""
printer.set(align='left', font='a', width=1,
printer.set(align='left', font='a', width=1, text_type="normal",
height=1, density=9, invert=False, smooth=False, flip=False)
@ -69,15 +68,26 @@ def print_weather(printer):
current_day = today.strftime("%a, %d %b, %Y")
printer.set(align="center",
font="a")
font="a",
text_type="b")
printer.text(f"{current_day}\n\n{city}\n")
reset_defaults(printer)
printer.set(align="center", font="b")
description = weather['weather'][0]['description']
printer.text(f"{description}\n")
printer.text(f"{description}\n\n")
icon_code = weather['weather'][0]['icon']
if not os.path.exists(f"icons/weather/{icon_code}.png"):
icon_path = "icons/weather/any.png"
else:
icon_path = f"icons/weather/{icon_code}.png"
printer.image(icon_path,
impl="bitImageColumn")
printer.text("\n")
# TODO: Print a nice icon based on the codes here: https://openweathermap.org/weather-conditions
temperature = weather['main']['temp']
humidity = weather['main']['humidity']

Loading…
Cancel
Save