1+ # SPDX-FileCopyrightText: 2024 Trevor Beaton for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
15import time
26import terminalio
37from adafruit_matrixportal .matrixportal import MatrixPortal
2327WEATHER_IMAGES = {
2428 "Sunny" : "images/sunny.bmp" ,
2529 "Clear" : "images/moon.bmp" ,
26- "Cloudy " : "images/cloudy.bmp" ,
30+ "Cldy " : "images/cloudy.bmp" , # Updated to use shortened version
2731 "Drizzle" : "images/rain.bmp" ,
2832 "Rainy" : "images/cloudy.bmp" ,
2933 "Heavy rain" : "images/rain.bmp" ,
30- "Thunderstorms" : "images/thunder.bmp" ,
31- "Isolated thunderstorms" : "images/thunder.bmp" ,
32- "Scattered thunderstorms" : "images/thunder.bmp" ,
33- "Strong storms" : "images/thunder.bmp" ,
34+ "TStorms" : "images/thunder.bmp" ,
3435 "Sun showers" : "images/rain.bmp" ,
3536 "Snow" : "images/snow.bmp" ,
36- "Light snow" : "images/snow.bmp" ,
37- "Heavy snow" : "images/snow.bmp" ,
3837}
3938
4039# Update this to your weather feed
@@ -56,12 +55,13 @@ def is_daytime(hour):
5655def clean_condition (condition , is_day ):
5756 condition = condition .replace ("Mostly " , "" ).replace ("Partly " , "" )
5857 condition_mapping = {
58+ "Cloudy" : "Cldy" , # Added shortened version of Cloudy
5959 "Drizzle or light rain" : "Rainy" ,
6060 "Heavy rain" : "Rainy" ,
61- "Isolated thunderstorms" : "Thunderstorms " ,
61+ "Isolated thunderstorms" : "TStorms " ,
6262 "Sun showers" : "Rainy" ,
63- "Scattered thunderstorms" : "Thunderstorms " ,
64- "Strong storms" : "Thunderstorms " ,
63+ "Scattered thunderstorms" : "TStorms " ,
64+ "Strong storms" : "TStorms " ,
6565 "Light snow" : "Snow" ,
6666 "Heavy snow" : "Snow" ,
6767 }
@@ -109,7 +109,7 @@ def update_display():
109109 print (f"Error loading image for { current_condition } : { e } " )
110110 else :
111111 print (f"Failed to parse weather data: { weather_data } " )
112- matrixportal .set_text ("Parse Error" , 0 )
112+ matrixportal .set_text ("Error" , 0 )
113113 matrixportal .set_text ("" , 1 )
114114 else :
115115 print ("Failed to retrieve data from feed" )
@@ -126,4 +126,4 @@ def update_display():
126126 update_display ()
127127 last_update = current_time
128128
129- time .sleep (1 ) # Sleep for 1 second
129+ time .sleep (1 ) # Sleep for 1 second
0 commit comments