diff --git a/icons/weather/01d.png b/icons/weather/01d.png new file mode 100644 index 0000000..86c37bd Binary files /dev/null and b/icons/weather/01d.png differ diff --git a/icons/weather/01n.png b/icons/weather/01n.png new file mode 100644 index 0000000..3419301 Binary files /dev/null and b/icons/weather/01n.png differ diff --git a/icons/weather/02d.png b/icons/weather/02d.png new file mode 100644 index 0000000..38e4252 Binary files /dev/null and b/icons/weather/02d.png differ diff --git a/icons/weather/02n.png b/icons/weather/02n.png new file mode 100644 index 0000000..6a13720 Binary files /dev/null and b/icons/weather/02n.png differ diff --git a/icons/weather/03d.png b/icons/weather/03d.png new file mode 100644 index 0000000..694471b Binary files /dev/null and b/icons/weather/03d.png differ diff --git a/icons/weather/03n.png b/icons/weather/03n.png new file mode 100644 index 0000000..694471b Binary files /dev/null and b/icons/weather/03n.png differ diff --git a/icons/weather/04d.png b/icons/weather/04d.png new file mode 100644 index 0000000..fc1329c Binary files /dev/null and b/icons/weather/04d.png differ diff --git a/icons/weather/04n.png b/icons/weather/04n.png new file mode 100644 index 0000000..fc1329c Binary files /dev/null and b/icons/weather/04n.png differ diff --git a/icons/weather/09d.png b/icons/weather/09d.png new file mode 100644 index 0000000..664cf82 Binary files /dev/null and b/icons/weather/09d.png differ diff --git a/icons/weather/09n.png b/icons/weather/09n.png new file mode 100644 index 0000000..664cf82 Binary files /dev/null and b/icons/weather/09n.png differ diff --git a/icons/weather/10d.png b/icons/weather/10d.png new file mode 100644 index 0000000..664cf82 Binary files /dev/null and b/icons/weather/10d.png differ diff --git a/icons/weather/10n.png b/icons/weather/10n.png new file mode 100644 index 0000000..664cf82 Binary files /dev/null and b/icons/weather/10n.png differ diff --git a/icons/weather/11d.png b/icons/weather/11d.png new file mode 100644 index 0000000..9a65d90 Binary files /dev/null and b/icons/weather/11d.png differ diff --git a/icons/weather/11n.png b/icons/weather/11n.png new file mode 100644 index 0000000..9a65d90 Binary files /dev/null and b/icons/weather/11n.png differ diff --git a/icons/weather/13d.png b/icons/weather/13d.png new file mode 100644 index 0000000..90ca825 Binary files /dev/null and b/icons/weather/13d.png differ diff --git a/icons/weather/13n.png b/icons/weather/13n.png new file mode 100644 index 0000000..90ca825 Binary files /dev/null and b/icons/weather/13n.png differ diff --git a/icons/weather/50d.png b/icons/weather/50d.png new file mode 100644 index 0000000..abd5614 Binary files /dev/null and b/icons/weather/50d.png differ diff --git a/icons/weather/50n.png b/icons/weather/50n.png new file mode 100644 index 0000000..abd5614 Binary files /dev/null and b/icons/weather/50n.png differ diff --git a/icons/weather/any.png b/icons/weather/any.png new file mode 100644 index 0000000..f384f83 Binary files /dev/null and b/icons/weather/any.png differ diff --git a/smallprint.py b/smallprint.py index fd0dd2f..a2bbf84 100644 --- a/smallprint.py +++ b/smallprint.py @@ -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']