From 809cb07bb8bb513a9e57e4b1912d394d79cb70a5 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 10 Aug 2025 20:46:41 -0500 Subject: [PATCH] on demand displays --- src/milb_manager.py | 43 ++++--- templates/index_v2.html | 130 ++++++++++++++++++-- web_interface_v2.py | 266 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 411 insertions(+), 28 deletions(-) diff --git a/src/milb_manager.py b/src/milb_manager.py index d5c4425f..8d2fc2df 100644 --- a/src/milb_manager.py +++ b/src/milb_manager.py @@ -318,25 +318,40 @@ class BaseMiLBManager: date_font = ImageFont.load_default() time_font = ImageFont.load_default() - # Draw date in center - date_width = draw.textlength(game_date_str, font=date_font) + # Draw date in center (use DisplayManager helpers for compatibility) + try: + date_width = self.display_manager.get_text_width(game_date_str, date_font) + except Exception: + # Fallback: approximate width by character count if helper fails + date_width = len(game_date_str) * 6 + date_height = self.display_manager.get_font_height(date_font) date_x = (width - date_width) // 2 - date_y = (height - date_font.size) // 2 - 3 - self.logger.debug(f"[MiLB] Drawing date '{game_date_str}' at ({date_x}, {date_y})") + date_y = (height - date_height) // 2 - 3 + self.logger.debug(f"[MiLB] Drawing date '{game_date_str}' at ({date_x}, {date_y}), size {date_width}x{date_height}") self._draw_text_with_outline(draw, game_date_str, (date_x, date_y), date_font) - - # Draw a simple test rectangle to verify drawing is working - draw.rectangle([date_x-2, date_y-2, date_x+date_width+2, date_y+date_font.size+2], outline=(255, 0, 0)) - + + # Debug rectangle around date text + try: + draw.rectangle([date_x-2, date_y-2, date_x+max(0, date_width)+2, date_y+date_height+2], outline=(255, 0, 0)) + except Exception: + pass + # Draw time below date - time_width = draw.textlength(game_time_formatted_str, font=time_font) + try: + time_width = self.display_manager.get_text_width(game_time_formatted_str, time_font) + except Exception: + time_width = len(game_time_formatted_str) * 6 + time_height = self.display_manager.get_font_height(time_font) time_x = (width - time_width) // 2 - time_y = date_y + 10 - self.logger.debug(f"[MiLB] Drawing time '{game_time_formatted_str}' at ({time_x}, {time_y})") + time_y = date_y + date_height + 2 + self.logger.debug(f"[MiLB] Drawing time '{game_time_formatted_str}' at ({time_x}, {time_y}), size {time_width}x{time_height}") self._draw_text_with_outline(draw, game_time_formatted_str, (time_x, time_y), time_font) - - # Draw a simple test rectangle to verify drawing is working - draw.rectangle([time_x-2, time_y-2, time_x+time_width+2, time_y+time_font.size+2], outline=(0, 255, 0)) + + # Debug rectangle around time text + try: + draw.rectangle([time_x-2, time_y-2, time_x+max(0, time_width)+2, time_y+time_height+2], outline=(0, 255, 0)) + except Exception: + pass # For recent/final games, show scores and status elif game_data['status'] in ['status_final', 'final', 'completed']: diff --git a/templates/index_v2.html b/templates/index_v2.html index 64ea2ded..5b8ef708 100644 --- a/templates/index_v2.html +++ b/templates/index_v2.html @@ -720,6 +720,8 @@ + + On-Demand: None
Service actions may require sudo privileges on the Pi.
@@ -1147,7 +1149,14 @@
-

Weather Configuration

+
+

Weather Configuration

+
+ + + +
+