mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 21:33:00 +00:00
Update daily forecast: Match modern layout with separate high/low temps
This commit is contained in:
@@ -396,42 +396,65 @@ class WeatherManager:
|
|||||||
# Clear once at the start
|
# Clear once at the start
|
||||||
self.display_manager.clear()
|
self.display_manager.clear()
|
||||||
|
|
||||||
# Display 3 days
|
# Create a new image for drawing
|
||||||
days_to_show = min(3, len(self.daily_forecast))
|
image = Image.new('RGB', (self.display_manager.matrix.width, self.display_manager.matrix.height))
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
|
# Display 5 days
|
||||||
|
days_to_show = min(5, len(self.daily_forecast))
|
||||||
section_width = self.display_manager.matrix.width // days_to_show
|
section_width = self.display_manager.matrix.width // days_to_show
|
||||||
|
|
||||||
for i in range(days_to_show):
|
for i in range(days_to_show):
|
||||||
forecast = current_state[i]
|
forecast = self.daily_forecast[i]
|
||||||
x = i * section_width
|
x = i * section_width
|
||||||
|
center_x = x + section_width // 2
|
||||||
|
|
||||||
# Draw day name
|
# Draw day name at top - using small font
|
||||||
self.display_manager.draw_text(
|
day_text = forecast['date'] # Already in "Fri" format
|
||||||
forecast['date'].upper(),
|
day_width = draw.textlength(day_text, font=self.display_manager.small_font)
|
||||||
x=x + 2,
|
draw.text((center_x - day_width // 2, 1),
|
||||||
y=2,
|
day_text,
|
||||||
color=self.COLORS['text'],
|
font=self.display_manager.small_font,
|
||||||
small_font=True
|
fill=self.COLORS['extra_dim'])
|
||||||
)
|
|
||||||
|
|
||||||
# Draw weather icon
|
# Draw weather icon in middle - made larger and centered
|
||||||
self.display_manager.draw_weather_icon(
|
icon_size = self.ICON_SIZE['medium']
|
||||||
forecast['condition'],
|
icon_y = 8 # Adjusted for better spacing
|
||||||
x=x + (section_width - self.ICON_SIZE['medium']) // 2,
|
icon_x = center_x - icon_size // 2
|
||||||
y=12,
|
|
||||||
size=self.ICON_SIZE['medium']
|
|
||||||
)
|
|
||||||
|
|
||||||
# Draw temperature range
|
# Map weather condition to icon and draw it
|
||||||
temp = f"{forecast['temp_low']}/{forecast['temp_high']}°" # Swapped order: low/high
|
condition = forecast['condition']
|
||||||
self.display_manager.draw_text(
|
if condition in ['Clear', 'Sunny']:
|
||||||
temp,
|
self.display_manager.draw_sun(icon_x, icon_y, icon_size)
|
||||||
x=x + (section_width - len(temp) * 4) // 2,
|
elif condition in ['Clouds', 'Cloudy', 'Partly Cloudy']:
|
||||||
y=24,
|
self.display_manager.draw_cloud(icon_x, icon_y, icon_size)
|
||||||
color=self.COLORS['highlight'],
|
elif condition in ['Rain', 'Drizzle', 'Shower']:
|
||||||
small_font=True
|
self.display_manager.draw_rain(icon_x, icon_y, icon_size)
|
||||||
)
|
elif condition in ['Snow', 'Sleet', 'Hail']:
|
||||||
|
self.display_manager.draw_snow(icon_x, icon_y, icon_size)
|
||||||
|
elif condition in ['Thunderstorm', 'Storm']:
|
||||||
|
self.display_manager.draw_storm(icon_x, icon_y, icon_size)
|
||||||
|
else:
|
||||||
|
self.display_manager.draw_sun(icon_x, icon_y, icon_size) # Default to sun
|
||||||
|
|
||||||
|
# Draw high temperature - using small font
|
||||||
|
high_text = f"{forecast['temp_high']}°"
|
||||||
|
high_width = draw.textlength(high_text, font=self.display_manager.small_font)
|
||||||
|
draw.text((center_x - high_width // 2, 24),
|
||||||
|
high_text,
|
||||||
|
font=self.display_manager.small_font,
|
||||||
|
fill=self.COLORS['text'])
|
||||||
|
|
||||||
|
# Draw low temperature below high - using small font and dimmer color
|
||||||
|
low_text = f"{forecast['temp_low']}°"
|
||||||
|
low_width = draw.textlength(low_text, font=self.display_manager.small_font)
|
||||||
|
draw.text((center_x - low_width // 2, 26),
|
||||||
|
low_text,
|
||||||
|
font=self.display_manager.small_font,
|
||||||
|
fill=self.COLORS['extra_dim'])
|
||||||
|
|
||||||
# Update display once after all elements are drawn
|
# Update the display
|
||||||
|
self.display_manager.image = image
|
||||||
self.display_manager.update_display()
|
self.display_manager.update_display()
|
||||||
self.last_daily_state = current_state
|
self.last_daily_state = current_state
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user