mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-29 03:53:00 +00:00
Limit daily forecast to 3 days and adjust spacing
This commit is contained in:
@@ -149,8 +149,8 @@ class WeatherManager:
|
||||
# Sort data by date to ensure chronological order
|
||||
sorted_daily_items = sorted(daily_data.items(), key=lambda item: item[1]['date'])
|
||||
|
||||
# Filter out today's data and take the next 4 days
|
||||
future_days_data = [item for item in sorted_daily_items if item[0] != today_str][:4]
|
||||
# Filter out today's data and take the next 3 days
|
||||
future_days_data = [item for item in sorted_daily_items if item[0] != today_str][:3]
|
||||
|
||||
for date_str, data in future_days_data:
|
||||
temps = data['temps']
|
||||
@@ -401,16 +401,20 @@ class WeatherManager:
|
||||
image = Image.new('RGB', (self.display_manager.matrix.width, self.display_manager.matrix.height))
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Calculate layout based on matrix dimensions
|
||||
days_to_show = min(4, len(self.daily_forecast))
|
||||
# Calculate layout based on matrix dimensions for 3 days
|
||||
days_to_show = min(3, len(self.daily_forecast)) # Changed from 4 to 3
|
||||
if days_to_show == 0:
|
||||
# Handle case where there's no forecast data after filtering
|
||||
draw.text((2, 2), "No daily forecast", font=self.display_manager.small_font, fill=self.COLORS['dim'])
|
||||
else:
|
||||
total_width = self.display_manager.matrix.width
|
||||
section_width = total_width // days_to_show
|
||||
padding = max(2, section_width // 6) # Increased padding for more space
|
||||
section_width = total_width // days_to_show # Divide by 3 (or fewer if less data)
|
||||
padding = max(2, section_width // 6)
|
||||
|
||||
for i in range(days_to_show):
|
||||
forecast = self.daily_forecast[i]
|
||||
x = i * section_width + padding
|
||||
center_x = x + (section_width - 2 * padding) // 2
|
||||
x = i * section_width # No need for padding here, centering handles spacing
|
||||
center_x = x + section_width // 2 # Center within the section
|
||||
|
||||
# Draw day name at top
|
||||
day_text = forecast['date']
|
||||
|
||||
Reference in New Issue
Block a user