From 8112f742761c16b828c63f9d4e0aaa33654df96c Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Sat, 19 Apr 2025 21:27:31 -0500 Subject: [PATCH] fix: force display updates for live NHL games when new data is received --- src/display_controller.py | 66 +++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/display_controller.py b/src/display_controller.py index 5543ad86..a098f4a5 100644 --- a/src/display_controller.py +++ b/src/display_controller.py @@ -308,6 +308,13 @@ class DisplayController: # Check for live games has_live_games, sport_type = self._check_live_games() + # If we have live games, update their display immediately + if has_live_games: + if sport_type == 'nhl' and self.nhl_live: + self.nhl_live.display(force_clear=True) + elif sport_type == 'nba' and self.nba_live: + self.nba_live.display(force_clear=True) + # Check for mode switch if current_time - self.last_switch > self.get_current_duration(): # If there are live games, check if they involve favorite teams @@ -361,38 +368,35 @@ class DisplayController: self.force_clear = True self.last_switch = current_time - # Display current mode frame + # Display current mode frame (only for non-live modes) try: - if self.current_display_mode == 'clock' and self.clock: - self.clock.display_time(force_clear=self.force_clear) - - elif self.current_display_mode == 'weather_current' and self.weather: - self.weather.display_weather(force_clear=self.force_clear) - elif self.current_display_mode == 'weather_hourly' and self.weather: - self.weather.display_hourly_forecast(force_clear=self.force_clear) - elif self.current_display_mode == 'weather_daily' and self.weather: - self.weather.display_daily_forecast(force_clear=self.force_clear) - - elif self.current_display_mode == 'stocks' and self.stocks: - self.stocks.display_stocks(force_clear=self.force_clear) - - elif self.current_display_mode == 'nhl_live' and self.nhl_live: - self.nhl_live.display(force_clear=self.force_clear) - elif self.current_display_mode == 'nhl_recent' and self.nhl_recent: - self.nhl_recent.display(force_clear=self.force_clear) - elif self.current_display_mode == 'nhl_upcoming' and self.nhl_upcoming: - self.nhl_upcoming.display(force_clear=self.force_clear) - - elif self.current_display_mode == 'nba_live' and self.nba_live: - self.nba_live.display(force_clear=self.force_clear) - elif self.current_display_mode == 'nba_recent' and self.nba_recent: - self.nba_recent.display(force_clear=self.force_clear) - elif self.current_display_mode == 'nba_upcoming' and self.nba_upcoming: - self.nba_upcoming.display(force_clear=self.force_clear) - - elif self.current_display_mode == 'stock_news' and self.news: - self.news.display_news() - + if self.current_display_mode != 'nhl_live' and self.current_display_mode != 'nba_live': + if self.current_display_mode == 'clock' and self.clock: + self.clock.display_time(force_clear=self.force_clear) + + elif self.current_display_mode == 'weather_current' and self.weather: + self.weather.display_weather(force_clear=self.force_clear) + elif self.current_display_mode == 'weather_hourly' and self.weather: + self.weather.display_hourly_forecast(force_clear=self.force_clear) + elif self.current_display_mode == 'weather_daily' and self.weather: + self.weather.display_daily_forecast(force_clear=self.force_clear) + + elif self.current_display_mode == 'stocks' and self.stocks: + self.stocks.display_stocks(force_clear=self.force_clear) + + elif self.current_display_mode == 'nhl_recent' and self.nhl_recent: + self.nhl_recent.display(force_clear=self.force_clear) + elif self.current_display_mode == 'nhl_upcoming' and self.nhl_upcoming: + self.nhl_upcoming.display(force_clear=self.force_clear) + + elif self.current_display_mode == 'nba_recent' and self.nba_recent: + self.nba_recent.display(force_clear=self.force_clear) + elif self.current_display_mode == 'nba_upcoming' and self.nba_upcoming: + self.nba_upcoming.display(force_clear=self.force_clear) + + elif self.current_display_mode == 'stock_news' and self.news: + self.news.display_news() + except Exception as e: logger.error(f"Error updating display for mode {self.current_display_mode}: {e}", exc_info=True) continue