Added icons and changed the printing image method
BIN
icons/weather/01d.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
icons/weather/01n.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
icons/weather/02d.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
icons/weather/02n.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
icons/weather/03d.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
icons/weather/03n.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
icons/weather/04d.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
icons/weather/04n.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
icons/weather/09d.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
icons/weather/09n.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
icons/weather/10d.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
icons/weather/10n.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
icons/weather/11d.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
icons/weather/11n.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
icons/weather/13d.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
icons/weather/13n.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
icons/weather/50d.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
icons/weather/50n.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
icons/weather/any.png
Normal file
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']
|
||||
|
|