feat: Add soccer scoreboard display

This commit is contained in:
ChuckBuilds
2025-04-30 13:34:59 -05:00
parent af30cc1441
commit 890770bf2a
2 changed files with 1143 additions and 194 deletions

View File

@@ -20,6 +20,7 @@ from src.stock_news_manager import StockNewsManager
from src.nhl_managers import NHLLiveManager, NHLRecentManager, NHLUpcomingManager
from src.nba_managers import NBALiveManager, NBARecentManager, NBAUpcomingManager
from src.mlb_manager import MLBLiveManager, MLBRecentManager, MLBUpcomingManager
from src.soccer_managers import SoccerLiveManager, SoccerRecentManager, SoccerUpcomingManager
from src.youtube_display import YouTubeDisplay
from src.calendar_manager import CalendarManager
from src.text_display import TextDisplay
@@ -66,8 +67,10 @@ class DisplayController:
self.nhl_live = None
self.nhl_recent = None
self.nhl_upcoming = None
logger.info("NHL managers initialized in %.3f seconds", time.time() - nhl_time)
# Initialize NBA managers if enabled
nba_time = time.time()
nba_enabled = self.config.get('nba_scoreboard', {}).get('enabled', False)
nba_display_modes = self.config.get('nba_scoreboard', {}).get('display_modes', {})
@@ -79,6 +82,7 @@ class DisplayController:
self.nba_live = None
self.nba_recent = None
self.nba_upcoming = None
logger.info("NBA managers initialized in %.3f seconds", time.time() - nba_time)
# Initialize MLB managers if enabled
mlb_time = time.time()
@@ -93,7 +97,23 @@ class DisplayController:
self.mlb_live = None
self.mlb_recent = None
self.mlb_upcoming = None
logger.info("MLB managers initialized in %.3f seconds", time.time() - mlb_time)
# Initialize Soccer managers if enabled
soccer_time = time.time()
soccer_enabled = self.config.get('soccer_scoreboard', {}).get('enabled', False)
soccer_display_modes = self.config.get('soccer_scoreboard', {}).get('display_modes', {})
if soccer_enabled:
self.soccer_live = SoccerLiveManager(self.config, self.display_manager) if soccer_display_modes.get('soccer_live', True) else None
self.soccer_recent = SoccerRecentManager(self.config, self.display_manager) if soccer_display_modes.get('soccer_recent', True) else None
self.soccer_upcoming = SoccerUpcomingManager(self.config, self.display_manager) if soccer_display_modes.get('soccer_upcoming', True) else None
else:
self.soccer_live = None
self.soccer_recent = None
self.soccer_upcoming = None
logger.info("Soccer managers initialized in %.3f seconds", time.time() - soccer_time)
# Track MLB rotation state
self.mlb_current_team_index = 0
self.mlb_showing_recent = True
@@ -124,9 +144,15 @@ class DisplayController:
# Add MLB display modes if enabled
if mlb_enabled:
if mlb_display_modes.get('mlb_recent', True): self.available_modes.append('mlb_recent')
if mlb_display_modes.get('mlb_upcoming', True): self.available_modes.append('mlb_upcoming')
if self.mlb_recent: self.available_modes.append('mlb_recent') # Use recent if mode enabled
if self.mlb_upcoming: self.available_modes.append('mlb_upcoming') # Use upcoming if mode enabled
# mlb_live is handled separately when live games are available
# Add Soccer display modes if enabled
if soccer_enabled:
if self.soccer_recent: self.available_modes.append('soccer_recent')
if self.soccer_upcoming: self.available_modes.append('soccer_upcoming')
# soccer_live is handled separately when live games are available
# Set initial display to first available mode (clock)
self.current_mode_index = 0
@@ -135,7 +161,7 @@ class DisplayController:
self.force_clear = True
self.update_interval = 0.01 # Reduced from 0.1 to 0.01 for smoother scrolling
# Track team-based rotation states
# Track team-based rotation states (Add Soccer)
self.nhl_current_team_index = 0
self.nhl_showing_recent = True
self.nhl_favorite_teams = self.config.get('nhl_scoreboard', {}).get('favorite_teams', [])
@@ -146,8 +172,15 @@ class DisplayController:
self.nba_favorite_teams = self.config.get('nba_scoreboard', {}).get('favorite_teams', [])
self.in_nba_rotation = False
self.soccer_current_team_index = 0 # Soccer rotation state
self.soccer_showing_recent = True
self.soccer_favorite_teams = self.config.get('soccer_scoreboard', {}).get('favorite_teams', [])
self.in_soccer_rotation = False
# Update display durations to include all modes
self.display_durations = self.config['display'].get('display_durations', {
self.display_durations = self.config['display'].get('display_durations', {})
# Add defaults for soccer if missing
default_durations = {
'clock': 15,
'weather_current': 15,
'weather_hourly': 15,
@@ -164,27 +197,36 @@ class DisplayController:
'nba_upcoming': 20,
'mlb_live': 30,
'mlb_recent': 20,
'mlb_upcoming': 20
})
'mlb_upcoming': 20,
'soccer_live': 30, # Soccer durations
'soccer_recent': 20,
'soccer_upcoming': 20
}
# Merge loaded durations with defaults
for key, value in default_durations.items():
if key not in self.display_durations:
self.display_durations[key] = value
logger.info("DisplayController initialized with display_manager: %s", id(self.display_manager))
logger.info(f"Available display modes: {self.available_modes}")
logger.info(f"NHL Favorite teams: {self.nhl_favorite_teams}")
logger.info(f"NBA Favorite teams: {self.nba_favorite_teams}")
logger.info(f"MLB Favorite teams: {self.mlb_favorite_teams}")
logger.info("NHL managers initialized in %.3f seconds", time.time() - nhl_time)
logger.info("MLB managers initialized in %.3f seconds", time.time() - mlb_time)
logger.info(f"Soccer Favorite teams: {self.soccer_favorite_teams}") # Log Soccer teams
# Removed redundant NHL/MLB init time logs
def get_current_duration(self) -> int:
"""Get the duration for the current display mode."""
mode_key = self.current_display_mode
# Simplify weather key handling
if mode_key.startswith('weather_'):
duration_key = mode_key.split('_', 1)[1]
if duration_key == 'current': duration_key = 'weather'
elif duration_key == 'hourly': duration_key = 'hourly_forecast'
elif duration_key == 'daily': duration_key = 'daily_forecast'
else: duration_key = 'weather'
return self.display_durations.get(duration_key, 15)
return self.display_durations.get(mode_key, 15)
# duration_key = mode_key.split('_', 1)[1]
# if duration_key == 'current': duration_key = 'weather_current' # Keep specific keys
# elif duration_key == 'hourly': duration_key = 'weather_hourly'
# elif duration_key == 'daily': duration_key = 'weather_daily'
# else: duration_key = 'weather_current' # Default to current
# return self.display_durations.get(duration_key, 15)
return self.display_durations.get(mode_key, 15)
@@ -211,23 +253,29 @@ class DisplayController:
if self.mlb_live: self.mlb_live.update()
if self.mlb_recent: self.mlb_recent.update()
if self.mlb_upcoming: self.mlb_upcoming.update()
# Update Soccer managers
if self.soccer_live: self.soccer_live.update()
if self.soccer_recent: self.soccer_recent.update()
if self.soccer_upcoming: self.soccer_upcoming.update()
def _check_live_games(self) -> tuple[bool, str]:
"""
Check if there are any live games available.
Returns:
tuple[bool, str]: (has_live_games, sport_type)
sport_type will be 'nhl', 'nba', 'mlb' or None
sport_type will be 'nhl', 'nba', 'mlb', 'soccer' or None
"""
# Check NHL live games
# Prioritize sports (e.g., Soccer > NHL > NBA > MLB)
if self.soccer_live and self.soccer_live.live_games:
return True, 'soccer'
if self.nhl_live and self.nhl_live.live_games:
return True, 'nhl'
# Check NBA live games
if self.nba_live and self.nba_live.live_games:
return True, 'nba'
# Check MLB live games
if self.mlb_live and self.mlb_live.live_games:
return True, 'mlb'
@@ -238,114 +286,107 @@ class DisplayController:
Get games for a specific team and update the current game.
Args:
team: Team abbreviation
sport: 'nhl', 'nba', or 'mlb'
sport: 'nhl', 'nba', 'mlb', or 'soccer'
is_recent: Whether to look for recent or upcoming games
Returns:
bool: True if games were found and set
"""
manager_recent = None
manager_upcoming = None
games_list_attr = 'games_list' # Default for NHL/NBA
abbr_key_home = 'home_abbr'
abbr_key_away = 'away_abbr'
if sport == 'nhl':
if is_recent and self.nhl_recent:
# Find recent games for this team
for game in self.nhl_recent.games_list:
if game["home_abbr"] == team or game["away_abbr"] == team:
self.nhl_recent.current_game = game
return True
elif not is_recent and self.nhl_upcoming:
# Find upcoming games for this team
for game in self.nhl_upcoming.games_list:
if game["home_abbr"] == team or game["away_abbr"] == team:
self.nhl_upcoming.current_game = game
return True
manager_recent = self.nhl_recent
manager_upcoming = self.nhl_upcoming
elif sport == 'nba':
if is_recent and self.nba_recent:
# Find recent games for this team
for game in self.nba_recent.games_list:
if game["home_abbr"] == team or game["away_abbr"] == team:
self.nba_recent.current_game = game
return True
elif not is_recent and self.nba_upcoming:
# Find upcoming games for this team
for game in self.nba_upcoming.games_list:
if game["home_abbr"] == team or game["away_abbr"] == team:
self.nba_upcoming.current_game = game
return True
manager_recent = self.nba_recent
manager_upcoming = self.nba_upcoming
elif sport == 'mlb':
if is_recent and self.mlb_recent:
# Find recent games for this team
for game in self.mlb_recent.recent_games:
if game['home_team'] == team or game['away_team'] == team:
self.mlb_recent.current_game = game
return True
elif not is_recent and self.mlb_upcoming:
# Find upcoming games for this team
for game in self.mlb_upcoming.upcoming_games:
if game['home_team'] == team or game['away_team'] == team:
self.mlb_upcoming.current_game = game
return True
manager_recent = self.mlb_recent
manager_upcoming = self.mlb_upcoming
games_list_attr = 'recent_games' if is_recent else 'upcoming_games'
abbr_key_home = 'home_team' # MLB uses different keys
abbr_key_away = 'away_team'
elif sport == 'soccer':
manager_recent = self.soccer_recent
manager_upcoming = self.soccer_upcoming
games_list_attr = 'games_list' if is_recent else 'upcoming_games' # Soccer uses games_list/upcoming_games
manager = manager_recent if is_recent else manager_upcoming
if manager and hasattr(manager, games_list_attr):
game_list = getattr(manager, games_list_attr, [])
for game in game_list:
# Need to handle potential missing keys gracefully
home_team_abbr = game.get(abbr_key_home)
away_team_abbr = game.get(abbr_key_away)
if home_team_abbr == team or away_team_abbr == team:
manager.current_game = game
return True
return False
def _has_team_games(self, sport: str = 'nhl') -> bool:
"""Check if there are any games for favorite teams."""
favorite_teams = []
manager_recent = None
manager_upcoming = None
if sport == 'nhl':
return bool(self.nhl_favorite_teams and (self.nhl_recent or self.nhl_upcoming))
favorite_teams = self.nhl_favorite_teams
manager_recent = self.nhl_recent
manager_upcoming = self.nhl_upcoming
elif sport == 'nba':
return bool(self.nba_favorite_teams and (self.nba_recent or self.nba_upcoming))
favorite_teams = self.nba_favorite_teams
manager_recent = self.nba_recent
manager_upcoming = self.nba_upcoming
elif sport == 'mlb':
return bool(self.mlb_favorite_teams and (self.mlb_recent or self.mlb_upcoming))
return False
favorite_teams = self.mlb_favorite_teams
manager_recent = self.mlb_recent
manager_upcoming = self.mlb_upcoming
elif sport == 'soccer':
favorite_teams = self.soccer_favorite_teams
manager_recent = self.soccer_recent
manager_upcoming = self.soccer_upcoming
return bool(favorite_teams and (manager_recent or manager_upcoming))
def _rotate_team_games(self, sport: str = 'nhl') -> None:
"""Rotate through games for favorite teams."""
"""Rotate through games for favorite teams. (No longer used directly in loop)"""
# This logic is now mostly handled within each manager's display/update
# Keeping the structure in case direct rotation is needed later.
if not self._has_team_games(sport):
return
if sport == 'nhl':
if not self._has_team_games('nhl'): return
# Try to find games for current team
if not self.nhl_favorite_teams: return
current_team = self.nhl_favorite_teams[self.nhl_current_team_index]
found_games = self._get_team_games(current_team, 'nhl', self.nhl_showing_recent)
if not found_games:
# Try opposite type (recent/upcoming) for same team
self.nhl_showing_recent = not self.nhl_showing_recent
found_games = self._get_team_games(current_team, 'nhl', self.nhl_showing_recent)
if not found_games:
# Move to next team
self.nhl_current_team_index = (self.nhl_current_team_index + 1) % len(self.nhl_favorite_teams)
self.nhl_showing_recent = True # Reset to recent games for next team
# ... (rest of NHL rotation logic - now less relevant)
elif sport == 'nba':
if not self._has_team_games('nba'): return
# Try to find games for current team
current_team = self.nba_favorite_teams[self.nba_current_team_index]
found_games = self._get_team_games(current_team, 'nba', self.nba_showing_recent)
if not found_games:
# Try opposite type (recent/upcoming) for same team
self.nba_showing_recent = not self.nba_showing_recent
found_games = self._get_team_games(current_team, 'nba', self.nba_showing_recent)
if not found_games:
# Move to next team
self.nba_current_team_index = (self.nba_current_team_index + 1) % len(self.nba_favorite_teams)
self.nba_showing_recent = True # Reset to recent games for next team
if not self.nba_favorite_teams: return
current_team = self.nba_favorite_teams[self.nba_current_team_index]
# ... (rest of NBA rotation logic)
elif sport == 'mlb':
if not self._has_team_games('mlb'): return
# Try to find games for current team
if not self.mlb_favorite_teams: return
current_team = self.mlb_favorite_teams[self.mlb_current_team_index]
found_games = self._get_team_games(current_team, 'mlb', self.mlb_showing_recent)
# ... (rest of MLB rotation logic)
elif sport == 'soccer':
if not self.soccer_favorite_teams: return
current_team = self.soccer_favorite_teams[self.soccer_current_team_index]
# Try to find games for current team (recent first)
found_games = self._get_team_games(current_team, 'soccer', self.soccer_showing_recent)
if not found_games:
# Try opposite type (upcoming/recent)
self.soccer_showing_recent = not self.soccer_showing_recent
found_games = self._get_team_games(current_team, 'soccer', self.soccer_showing_recent)
if not found_games:
# Try opposite type (recent/upcoming) for same team
self.mlb_showing_recent = not self.mlb_showing_recent
found_games = self._get_team_games(current_team, 'mlb', self.mlb_showing_recent)
if not found_games:
# Move to next team
self.mlb_current_team_index = (self.mlb_current_team_index + 1) % len(self.mlb_favorite_teams)
self.mlb_showing_recent = True # Reset to recent games for next team
# Move to next team if no games found for current one
self.soccer_current_team_index = (self.soccer_current_team_index + 1) % len(self.soccer_favorite_teams)
self.soccer_showing_recent = True # Reset to recent for the new team
# Maybe try finding game for the *new* team immediately? Optional.
def run(self):
"""Run the display controller, switching between displays."""
@@ -361,109 +402,150 @@ class DisplayController:
# Update data for all modules
self._update_modules()
# Check for live games
has_live_games, sport_type = self._check_live_games()
# Check for live games (priority: Soccer > NHL > NBA > MLB)
has_live_games, live_sport_type = self._check_live_games()
# If we have live games, cycle through them
# --- Live Game Handling ---
if has_live_games:
# Check if it's time to switch live games
if current_time - self.last_switch > self.get_current_duration():
# Switch between NHL, NBA, and MLB live games if multiple are available
if sport_type == 'nhl' and self.nba_live and self.nba_live.live_games:
sport_type = 'nba'
self.last_switch = current_time
self.force_clear = True
elif sport_type == 'nba' and self.mlb_live and self.mlb_live.live_games:
sport_type = 'mlb'
self.last_switch = current_time
self.force_clear = True
elif sport_type == 'mlb' and self.nhl_live and self.nhl_live.live_games:
sport_type = 'nhl'
self.last_switch = current_time
self.force_clear = True
# Determine which live manager to use
live_manager = None
if live_sport_type == 'soccer' and self.soccer_live:
live_manager = self.soccer_live
current_mode_for_duration = 'soccer_live'
elif live_sport_type == 'nhl' and self.nhl_live:
live_manager = self.nhl_live
current_mode_for_duration = 'nhl_live'
elif live_sport_type == 'nba' and self.nba_live:
live_manager = self.nba_live
current_mode_for_duration = 'nba_live'
elif live_sport_type == 'mlb' and self.mlb_live:
live_manager = self.mlb_live
current_mode_for_duration = 'mlb_live'
# Display the current live game
if sport_type == 'nhl' and self.nhl_live:
self.nhl_live.update() # Force update to get latest data
self.nhl_live.display(force_clear=self.force_clear)
elif sport_type == 'nba' and self.nba_live:
self.nba_live.update() # Force update to get latest data
self.nba_live.display(force_clear=self.force_clear)
elif sport_type == 'mlb' and self.mlb_live:
self.mlb_live.update() # Force update to get latest data
self.mlb_live.display(force_clear=self.force_clear)
self.force_clear = False
continue # Skip the rest of the loop to stay on live games
# Only proceed with mode switching if no live games
if current_time - self.last_switch > self.get_current_duration():
# No live games, continue with regular rotation
# If we're currently on calendar, advance to next event before switching modes
if self.current_display_mode == 'calendar' and self.calendar:
self.calendar.advance_event()
self.current_mode_index = (self.current_mode_index + 1) % len(self.available_modes)
self.current_display_mode = self.available_modes[self.current_mode_index]
logger.info(f"Switching to: {self.current_display_mode}")
self.force_clear = True
self.last_switch = current_time
if live_manager:
# Check if switching *into* live mode or switching *between* live sports
if self.current_display_mode != current_mode_for_duration:
logger.info(f"Switching to LIVE mode: {current_mode_for_duration}")
self.current_display_mode = current_mode_for_duration
self.force_clear = True
self.last_switch = current_time # Reset timer for live duration
# 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 == 'stock_news' and self.news:
self.news.display_news()
elif self.current_display_mode == 'calendar' and self.calendar:
self.calendar.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_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 == 'mlb_recent' and self.mlb_recent:
self.mlb_recent.display(force_clear=self.force_clear)
elif self.current_display_mode == 'mlb_upcoming' and self.mlb_upcoming:
self.mlb_upcoming.display(force_clear=self.force_clear)
elif self.current_display_mode == 'youtube' and self.youtube:
self.youtube.display(force_clear=self.force_clear)
elif self.current_display_mode == 'text_display' and self.text_display:
self.text_display.display()
except Exception as e:
logger.error(f"Error updating display for mode {self.current_display_mode}: {e}", exc_info=True)
continue
# Display the current live game using the selected manager
live_manager.display(force_clear=self.force_clear)
self.force_clear = False # Clear only once when switching
else:
# Should not happen if _check_live_games is correct, but handle defensively
has_live_games = False # Fall back to regular rotation
logger.warning("Live game detected but corresponding manager is None.")
self.force_clear = False
# --- Regular Mode Rotation (only if NO live games) ---
if not has_live_games:
# Check if we were just in live mode and need to switch back
if self.current_display_mode.endswith('_live'):
logger.info(f"Switching back to regular rotation from {self.current_display_mode}")
# Find the next available mode in the regular list
self.current_mode_index = (self.current_mode_index + 1) % len(self.available_modes)
self.current_display_mode = self.available_modes[self.current_mode_index]
self.force_clear = True
self.last_switch = current_time
logger.info(f"Switching to: {self.current_display_mode}")
# Check if it's time to switch modes based on duration
elif current_time - self.last_switch > self.get_current_duration():
# Advance calendar event before switching away
if self.current_display_mode == 'calendar' and self.calendar:
self.calendar.advance_event()
self.current_mode_index = (self.current_mode_index + 1) % len(self.available_modes)
self.current_display_mode = self.available_modes[self.current_mode_index]
logger.info(f"Switching to: {self.current_display_mode}")
self.force_clear = True
self.last_switch = current_time
# Display current mode frame
try:
display_updated = False # Flag to track if display was handled
if self.current_display_mode == 'clock' and self.clock:
self.clock.display_time(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'weather_current' and self.weather:
self.weather.display_weather(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'weather_hourly' and self.weather:
self.weather.display_hourly_forecast(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'weather_daily' and self.weather:
self.weather.display_daily_forecast(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'stocks' and self.stocks:
self.stocks.display_stocks(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'stock_news' and self.news:
self.news.display_news() # Assumes news handles its own clearing/drawing
display_updated = True
elif self.current_display_mode == 'calendar' and self.calendar:
self.calendar.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'nhl_recent' and self.nhl_recent:
self.nhl_recent.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'nhl_upcoming' and self.nhl_upcoming:
self.nhl_upcoming.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'nba_recent' and self.nba_recent:
self.nba_recent.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'nba_upcoming' and self.nba_upcoming:
self.nba_upcoming.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'mlb_recent' and self.mlb_recent:
self.mlb_recent.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'mlb_upcoming' and self.mlb_upcoming:
self.mlb_upcoming.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'soccer_recent' and self.soccer_recent:
self.soccer_recent.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'soccer_upcoming' and self.soccer_upcoming:
self.soccer_upcoming.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'youtube' and self.youtube:
self.youtube.display(force_clear=self.force_clear)
display_updated = True
elif self.current_display_mode == 'text_display' and self.text_display:
self.text_display.display() # Assumes text handles its own drawing
display_updated = True
# Reset force_clear only if a display method was actually called
if display_updated:
self.force_clear = False
except Exception as e:
logger.error(f"Error updating display for mode {self.current_display_mode}: {e}", exc_info=True)
# Continue to next iteration after error
# Small sleep to prevent high CPU usage
time.sleep(self.update_interval)
except KeyboardInterrupt:
logger.info("Display controller stopped by user")
except Exception as e:
logger.error(f"Error in display controller: {e}", exc_info=True)
logger.error(f"Critical error in display controller run loop: {e}", exc_info=True)
finally:
logger.info("Cleaning up display manager...")
self.display_manager.cleanup()
logger.info("Cleanup complete.")
def main():
controller = DisplayController()