mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-13 14:03:00 +00:00
change width draw logic in leaderboard display
This commit is contained in:
@@ -430,11 +430,9 @@ class DisplayController:
|
|||||||
logger.info(f"Initial display mode: {self.current_display_mode}")
|
logger.info(f"Initial display mode: {self.current_display_mode}")
|
||||||
logger.info("DisplayController initialized with display_manager: %s", id(self.display_manager))
|
logger.info("DisplayController initialized with display_manager: %s", id(self.display_manager))
|
||||||
|
|
||||||
# --- SCHEDULING & CONFIG REFRESH ---
|
# --- SCHEDULING ---
|
||||||
self.config_check_interval = 30
|
|
||||||
self.last_config_check = 0
|
|
||||||
self.is_display_active = True
|
self.is_display_active = True
|
||||||
self._load_config() # Initial load of schedule
|
self._load_schedule_config() # Load schedule config once at startup
|
||||||
|
|
||||||
def _handle_music_update(self, track_info: Dict[str, Any], significant_change: bool = False):
|
def _handle_music_update(self, track_info: Dict[str, Any], significant_change: bool = False):
|
||||||
"""Callback for when music track info changes."""
|
"""Callback for when music track info changes."""
|
||||||
@@ -865,14 +863,14 @@ class DisplayController:
|
|||||||
self.ncaa_fb_showing_recent = True # Reset to recent for the new team
|
self.ncaa_fb_showing_recent = True # Reset to recent for the new team
|
||||||
|
|
||||||
# --- SCHEDULING METHODS ---
|
# --- SCHEDULING METHODS ---
|
||||||
def _load_config(self):
|
def _load_schedule_config(self):
|
||||||
"""Load configuration from the config manager and parse schedule settings."""
|
"""Load schedule configuration once at startup."""
|
||||||
self.config = self.config_manager.load_config()
|
|
||||||
schedule_config = self.config.get('schedule', {})
|
schedule_config = self.config.get('schedule', {})
|
||||||
self.schedule_enabled = schedule_config.get('enabled', False)
|
self.schedule_enabled = schedule_config.get('enabled', False)
|
||||||
try:
|
try:
|
||||||
self.start_time = datetime.strptime(schedule_config.get('start_time', '07:00'), '%H:%M').time()
|
self.start_time = datetime.strptime(schedule_config.get('start_time', '07:00'), '%H:%M').time()
|
||||||
self.end_time = datetime.strptime(schedule_config.get('end_time', '22:00'), '%H:%M').time()
|
self.end_time = datetime.strptime(schedule_config.get('end_time', '22:00'), '%H:%M').time()
|
||||||
|
logger.info(f"Schedule loaded: enabled={self.schedule_enabled}, start={self.start_time}, end={self.end_time}")
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
logger.warning("Invalid time format in schedule config. Using defaults.")
|
logger.warning("Invalid time format in schedule config. Using defaults.")
|
||||||
self.start_time = time_obj(7, 0)
|
self.start_time = time_obj(7, 0)
|
||||||
@@ -962,12 +960,7 @@ class DisplayController:
|
|||||||
while True:
|
while True:
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
|
|
||||||
# Periodically check for config changes
|
# Check the schedule (no config reload needed)
|
||||||
if current_time - self.last_config_check > self.config_check_interval:
|
|
||||||
self._load_config()
|
|
||||||
self.last_config_check = current_time
|
|
||||||
|
|
||||||
# Enforce the schedule
|
|
||||||
self._check_schedule()
|
self._check_schedule()
|
||||||
if not self.is_display_active:
|
if not self.is_display_active:
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|||||||
@@ -887,7 +887,7 @@ class LeaderboardManager:
|
|||||||
|
|
||||||
# Move to next league section
|
# Move to next league section
|
||||||
current_x += teams_width + 20 # Teams width + spacing
|
current_x += teams_width + 20 # Teams width + spacing
|
||||||
current_x += spacing # Add spacing between leagues
|
# Note: spacing between leagues is already included in total_width calculation
|
||||||
|
|
||||||
# Set total scroll width for dynamic duration calculation
|
# Set total scroll width for dynamic duration calculation
|
||||||
self.total_scroll_width = total_width
|
self.total_scroll_width = total_width
|
||||||
@@ -930,7 +930,7 @@ class LeaderboardManager:
|
|||||||
|
|
||||||
league_width = league_logo_width + teams_width + 20
|
league_width = league_logo_width + teams_width + 20
|
||||||
logger.info(f"League {league_key}: {len(teams)} teams, width {league_width}px, starts at x={current_x}")
|
logger.info(f"League {league_key}: {len(teams)} teams, width {league_width}px, starts at x={current_x}")
|
||||||
current_x += league_width + spacing # Use same spacing as main calculation
|
current_x += league_width # No additional spacing - already included in total_width calculation
|
||||||
|
|
||||||
# Calculate dynamic duration using proper scroll-based calculation
|
# Calculate dynamic duration using proper scroll-based calculation
|
||||||
if self.dynamic_duration_enabled:
|
if self.dynamic_duration_enabled:
|
||||||
@@ -1040,7 +1040,7 @@ class LeaderboardManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error updating leaderboard for dynamic duration: {e}")
|
logger.error(f"Error updating leaderboard for dynamic duration: {e}")
|
||||||
|
|
||||||
logger.info(f"get_dynamic_duration called, returning: {self.dynamic_duration}s")
|
logger.debug(f"get_dynamic_duration called, returning: {self.dynamic_duration}s")
|
||||||
return self.dynamic_duration
|
return self.dynamic_duration
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user