Optimize weather display layout: Adjust sizes and spacing for 32x64 matrix

This commit is contained in:
ChuckBuilds
2025-04-11 13:52:01 -05:00
parent 88a05283dc
commit c7394eb8a6

View File

@@ -36,10 +36,10 @@ class WeatherManager:
self.daily_forecast = None self.daily_forecast = None
self.last_draw_time = 0 self.last_draw_time = 0
# Layout constants # Layout constants
self.PADDING = 2 self.PADDING = 1
self.ICON_SIZE = { self.ICON_SIZE = {
'large': 16, 'large': 12,
'medium': 12, 'medium': 10,
'small': 8 'small': 8
} }
self.COLORS = { self.COLORS = {
@@ -217,8 +217,8 @@ class WeatherManager:
# Draw weather condition icon and text at the top # Draw weather condition icon and text at the top
condition = weather_data['weather'][0]['main'] condition = weather_data['weather'][0]['main']
icon_x = 2 icon_x = 1
icon_y = 2 icon_y = 1
self.display_manager.draw_weather_icon( self.display_manager.draw_weather_icon(
condition, condition,
icon_x, icon_x,
@@ -226,64 +226,66 @@ class WeatherManager:
size=self.ICON_SIZE['large'] size=self.ICON_SIZE['large']
) )
# Draw condition text next to icon # Draw condition text next to icon (using small font)
condition_text = condition condition_text = condition
draw.text((icon_x + self.ICON_SIZE['large'] + 2, icon_y), draw.text((icon_x + self.ICON_SIZE['large'] + 1, icon_y),
condition_text, condition_text,
font=self.display_manager.regular_font, font=self.display_manager.small_font,
fill=self.COLORS['text']) fill=self.COLORS['text'])
# Draw "time ago" text below condition # Draw "time ago" text below condition (using small font)
time_since_update = int((time.time() - self.last_update) / 3600) # hours time_since_update = int((time.time() - self.last_update) / 3600) # hours
time_text = f"{time_since_update} hours ago" time_text = f"{time_since_update}h ago" # Shortened text
draw.text((icon_x + self.ICON_SIZE['large'] + 2, icon_y + 10), draw.text((icon_x + self.ICON_SIZE['large'] + 1, icon_y + 8),
time_text, time_text,
font=self.display_manager.small_font, font=self.display_manager.small_font,
fill=self.COLORS['text']) fill=self.COLORS['text'])
# Draw current temperature on the right # Draw current temperature on the right (using regular font)
temp = round(weather_data['main']['temp']) temp = round(weather_data['main']['temp'])
temp_text = f"{temp}°F" temp_text = f"{temp}°" # Shortened to just degrees
temp_x = self.display_manager.matrix.width - 30 # Adjust position as needed temp_width = draw.textlength(temp_text, font=self.display_manager.regular_font)
draw.text((temp_x, 2), temp_x = self.display_manager.matrix.width - temp_width - 2
draw.text((temp_x, 1),
temp_text, temp_text,
font=self.display_manager.regular_font, font=self.display_manager.regular_font,
fill=self.COLORS['highlight']) fill=self.COLORS['highlight'])
# Draw high/low temperatures below current temp # Draw high/low temperatures below current temp (using small font)
temp_max = round(weather_data['main']['temp_max']) temp_max = round(weather_data['main']['temp_max'])
temp_min = round(weather_data['main']['temp_min']) temp_min = round(weather_data['main']['temp_min'])
high_low_text = f"{temp_max}°F / {temp_min}°F" high_low_text = f"{temp_max}°/{temp_min}°" # Shortened format
draw.text((temp_x - 5, 12), high_low_width = draw.textlength(high_low_text, font=self.display_manager.small_font)
draw.text((self.display_manager.matrix.width - high_low_width - 2, 11),
high_low_text, high_low_text,
font=self.display_manager.small_font, font=self.display_manager.small_font,
fill=self.COLORS['text']) fill=self.COLORS['text'])
# Draw additional weather metrics # Draw additional weather metrics in bottom half
y_start = self.display_manager.matrix.height - 24 y_start = 18 # Start metrics lower
spacing = 8 spacing = 7 # Reduced spacing
# Air pressure # Air pressure (shortened format)
pressure = weather_data['main']['pressure'] * 0.02953 # Convert hPa to inHg pressure = weather_data['main']['pressure'] * 0.02953 # Convert hPa to inHg
pressure_text = f"Air pressure {pressure:.2f} inHg" pressure_text = f"Press: {pressure:.1f}in" # Shortened format
draw.text((2, y_start), draw.text((2, y_start),
pressure_text, pressure_text,
font=self.display_manager.small_font, font=self.display_manager.small_font,
fill=self.COLORS['text']) fill=self.COLORS['text'])
# Humidity # Humidity (shortened format)
humidity = weather_data['main']['humidity'] humidity = weather_data['main']['humidity']
humidity_text = f"Humidity {humidity}%" humidity_text = f"Hum: {humidity}%" # Shortened format
draw.text((2, y_start + spacing), draw.text((2, y_start + spacing),
humidity_text, humidity_text,
font=self.display_manager.small_font, font=self.display_manager.small_font,
fill=self.COLORS['text']) fill=self.COLORS['text'])
# Wind speed and direction # Wind speed and direction (shortened format)
wind_speed = weather_data['wind']['speed'] wind_speed = weather_data['wind']['speed']
wind_deg = weather_data.get('wind', {}).get('deg', 0) wind_deg = weather_data.get('wind', {}).get('deg', 0)
wind_dir = self._get_wind_direction(wind_deg) wind_dir = self._get_wind_direction(wind_deg)
wind_text = f"Wind speed {wind_speed:.2f} mph ({wind_dir})" wind_text = f"Wind: {wind_speed:.1f}mph {wind_dir}" # Shortened format
draw.text((2, y_start + spacing * 2), draw.text((2, y_start + spacing * 2),
wind_text, wind_text,
font=self.display_manager.small_font, font=self.display_manager.small_font,