From 44d58958ba0d4285445696ab32cd39abec43cfa9 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 24 Apr 2025 19:18:38 -0500 Subject: [PATCH] Add 10-second display duration for MLB upcoming games --- src/mlb_manager.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mlb_manager.py b/src/mlb_manager.py index 19216b73..73974283 100644 --- a/src/mlb_manager.py +++ b/src/mlb_manager.py @@ -534,12 +534,14 @@ class MLBUpcomingManager(BaseMLBManager): super().__init__(config, display_manager) self.logger.info("Initialized MLB Upcoming Manager") self.upcoming_games = [] - self.current_game = None # Initialize current_game + self.current_game = None self.current_game_index = 0 self.last_update = 0 self.update_interval = self.mlb_config.get('upcoming_update_interval', 3600) self.last_warning_time = 0 self.warning_cooldown = 300 # Only show warning every 5 minutes + self.last_game_switch = 0 # Track when we last switched games + self.game_display_duration = 10 # Display each game for 10 seconds logger.info(f"Initialized MLBUpcomingManager with {len(self.favorite_teams)} favorite teams") def update(self): @@ -609,15 +611,21 @@ class MLBUpcomingManager(BaseMLBManager): return # Skip display update entirely try: + current_time = time.time() + + # Check if it's time to switch games + if current_time - self.last_game_switch >= self.game_display_duration: + # Move to next game + self.current_game_index = (self.current_game_index + 1) % len(self.upcoming_games) + self.current_game = self.upcoming_games[self.current_game_index] + self.last_game_switch = current_time + force_clear = True # Force clear when switching games + # Create and display the game image game_image = self._create_game_display(self.current_game) self.display_manager.image = game_image self.display_manager.draw = ImageDraw.Draw(self.display_manager.image) self.display_manager.update_display() - # Move to next game - self.current_game_index = (self.current_game_index + 1) % len(self.upcoming_games) - self.current_game = self.upcoming_games[self.current_game_index] - except Exception as e: logger.error(f"[MLB] Error displaying upcoming game: {e}", exc_info=True) \ No newline at end of file