mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 13:23:00 +00:00
feat(weather): Adjust layout and use 4x6 font for details
Removed "time since update" text. Used 4x6.bdf font for pressure, humidity, and wind speed.
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import Dict, Any, List, Tuple
|
||||
import logging
|
||||
import math
|
||||
from .weather_icons import WeatherIcons
|
||||
import os
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@@ -128,12 +129,25 @@ class DisplayManager:
|
||||
# Use the same font for small text, just at a smaller size
|
||||
self.small_font = ImageFont.truetype("assets/fonts/PressStart2P-Regular.ttf", 8)
|
||||
logger.info("Press Start 2P small font loaded successfully")
|
||||
|
||||
|
||||
# Add an even smaller font using 4x6.bdf relative to script location
|
||||
try:
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
font_path = os.path.join(script_dir, "../assets/fonts/4x6.bdf")
|
||||
self.extra_small_font = ImageFont.load(font_path)
|
||||
logger.info(f"4x6.bdf extra small font loaded successfully from {font_path}")
|
||||
except Exception as font_err:
|
||||
logger.error(f"Failed to load 4x6.bdf font: {font_err}. Falling back.")
|
||||
self.extra_small_font = self.regular_font # Use regular as fallback
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in font loading: {e}")
|
||||
# Fallback to default font
|
||||
self.regular_font = ImageFont.load_default()
|
||||
self.small_font = self.regular_font
|
||||
# Ensure extra_small_font exists even if regular/small fail
|
||||
if not hasattr(self, 'extra_small_font'):
|
||||
self.extra_small_font = self.regular_font
|
||||
|
||||
def draw_text(self, text: str, x: int = None, y: int = None, color: Tuple[int, int, int] = (255, 255, 255), small_font: bool = False) -> None:
|
||||
"""Draw text on the display with improved clarity."""
|
||||
|
||||
Reference in New Issue
Block a user