1
+ # SPDX-FileCopyrightText: 2024 Trevor Beaton for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
1
5
import time
2
6
import terminalio
3
7
from adafruit_matrixportal .matrixportal import MatrixPortal
23
27
WEATHER_IMAGES = {
24
28
"Sunny" : "images/sunny.bmp" ,
25
29
"Clear" : "images/moon.bmp" ,
26
- "Cloudy " : "images/cloudy.bmp" ,
30
+ "Cldy " : "images/cloudy.bmp" , # Updated to use shortened version
27
31
"Drizzle" : "images/rain.bmp" ,
28
32
"Rainy" : "images/cloudy.bmp" ,
29
33
"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" ,
34
35
"Sun showers" : "images/rain.bmp" ,
35
36
"Snow" : "images/snow.bmp" ,
36
- "Light snow" : "images/snow.bmp" ,
37
- "Heavy snow" : "images/snow.bmp" ,
38
37
}
39
38
40
39
# Update this to your weather feed
@@ -56,12 +55,13 @@ def is_daytime(hour):
56
55
def clean_condition (condition , is_day ):
57
56
condition = condition .replace ("Mostly " , "" ).replace ("Partly " , "" )
58
57
condition_mapping = {
58
+ "Cloudy" : "Cldy" , # Added shortened version of Cloudy
59
59
"Drizzle or light rain" : "Rainy" ,
60
60
"Heavy rain" : "Rainy" ,
61
- "Isolated thunderstorms" : "Thunderstorms " ,
61
+ "Isolated thunderstorms" : "TStorms " ,
62
62
"Sun showers" : "Rainy" ,
63
- "Scattered thunderstorms" : "Thunderstorms " ,
64
- "Strong storms" : "Thunderstorms " ,
63
+ "Scattered thunderstorms" : "TStorms " ,
64
+ "Strong storms" : "TStorms " ,
65
65
"Light snow" : "Snow" ,
66
66
"Heavy snow" : "Snow" ,
67
67
}
@@ -109,7 +109,7 @@ def update_display():
109
109
print (f"Error loading image for { current_condition } : { e } " )
110
110
else :
111
111
print (f"Failed to parse weather data: { weather_data } " )
112
- matrixportal .set_text ("Parse Error" , 0 )
112
+ matrixportal .set_text ("Error" , 0 )
113
113
matrixportal .set_text ("" , 1 )
114
114
else :
115
115
print ("Failed to retrieve data from feed" )
@@ -126,4 +126,4 @@ def update_display():
126
126
update_display ()
127
127
last_update = current_time
128
128
129
- time .sleep (1 ) # Sleep for 1 second
129
+ time .sleep (1 ) # Sleep for 1 second
0 commit comments