troubleshooting weather forecast

weather forecast error resolution
This commit is contained in:
Chuck
2025-04-08 18:00:24 -05:00
parent eeb8e21564
commit df94535316
2 changed files with 47 additions and 14 deletions

View File

@@ -150,18 +150,32 @@ class WeatherManager:
if not weather_data:
return
current_time = time.time()
temp = round(weather_data['main']['temp'])
condition = weather_data['weather'][0]['main']
# Draw temperature text and weather icon
text = f"{temp}°F"
icon_x = (self.display_manager.matrix.width - 20) // 2 # Center the 20px icon
icon_y = 2 # Near the top
self.display_manager.draw_text_with_icons(
text,
icons=[(condition, icon_x, icon_y)],
force_clear=force_clear
)
# Only update display if forced or data changed
if force_clear or not hasattr(self, 'last_temp') or temp != self.last_temp or condition != self.last_condition:
# Draw temperature text and weather icon
text = f"{temp}°F"
icon_x = (self.display_manager.matrix.width - 20) // 2 # Center the 20px icon
icon_y = 2 # Near the top
# Clear and draw
if force_clear:
self.display_manager.clear()
# Draw icon and text
self.display_manager.draw_weather_icon(condition, icon_x, icon_y, size=16)
self.display_manager.draw_text(
text,
y=icon_y + 18, # Position text below icon
small_font=False
)
# Update cache
self.last_temp = temp
self.last_condition = condition
def display_hourly_forecast(self, scroll_amount: int = 0, force_clear: bool = False) -> None:
"""Display scrolling hourly forecast information."""