mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
Sports news ticker with dynamic headline scrolling (#9)
* Add news manager with RSS feed ticker and dynamic scrolling Co-authored-by: charlesmynard <charlesmynard@gmail.com> * Add F1 feeds, custom feed management script, and comprehensive feed guide Co-authored-by: charlesmynard <charlesmynard@gmail.com> * Remove emoji and improve error/success message formatting Co-authored-by: charlesmynard <charlesmynard@gmail.com> * Add dynamic duration feature for news display with configurable timing Co-authored-by: charlesmynard <charlesmynard@gmail.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
@@ -33,6 +33,7 @@ from src.calendar_manager import CalendarManager
|
||||
from src.text_display import TextDisplay
|
||||
from src.music_manager import MusicManager
|
||||
from src.of_the_day_manager import OfTheDayManager
|
||||
from src.news_manager import NewsManager
|
||||
|
||||
# Get logger without configuring
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -61,9 +62,11 @@ class DisplayController:
|
||||
self.youtube = YouTubeDisplay(self.display_manager, self.config) if self.config.get('youtube', {}).get('enabled', False) else None
|
||||
self.text_display = TextDisplay(self.display_manager, self.config) if self.config.get('text_display', {}).get('enabled', False) else None
|
||||
self.of_the_day = OfTheDayManager(self.display_manager, self.config) if self.config.get('of_the_day', {}).get('enabled', False) else None
|
||||
self.news_manager = NewsManager(self.config, self.display_manager) if self.config.get('news_manager', {}).get('enabled', False) else None
|
||||
logger.info(f"Calendar Manager initialized: {'Object' if self.calendar else 'None'}")
|
||||
logger.info(f"Text Display initialized: {'Object' if self.text_display else 'None'}")
|
||||
logger.info(f"OfTheDay Manager initialized: {'Object' if self.of_the_day else 'None'}")
|
||||
logger.info(f"News Manager initialized: {'Object' if self.news_manager else 'None'}")
|
||||
logger.info("Display modes initialized in %.3f seconds", time.time() - init_time)
|
||||
|
||||
# Initialize Music Manager
|
||||
@@ -255,6 +258,7 @@ class DisplayController:
|
||||
if self.youtube: self.available_modes.append('youtube')
|
||||
if self.text_display: self.available_modes.append('text_display')
|
||||
if self.of_the_day: self.available_modes.append('of_the_day')
|
||||
if self.news_manager: self.available_modes.append('news_manager')
|
||||
if self.music_manager:
|
||||
self.available_modes.append('music')
|
||||
# Add NHL display modes if enabled
|
||||
@@ -439,6 +443,17 @@ class DisplayController:
|
||||
"""Get the duration for the current display mode."""
|
||||
mode_key = self.current_display_mode
|
||||
|
||||
# Handle dynamic duration for news manager
|
||||
if mode_key == 'news_manager' and self.news_manager:
|
||||
try:
|
||||
dynamic_duration = self.news_manager.get_dynamic_duration()
|
||||
logger.info(f"Using dynamic duration for news_manager: {dynamic_duration} seconds")
|
||||
return dynamic_duration
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting dynamic duration for news_manager: {e}")
|
||||
# Fall back to configured duration
|
||||
return self.display_durations.get(mode_key, 60)
|
||||
|
||||
# Simplify weather key handling
|
||||
if mode_key.startswith('weather_'):
|
||||
return self.display_durations.get(mode_key, 15)
|
||||
@@ -461,6 +476,7 @@ class DisplayController:
|
||||
if self.youtube: self.youtube.update()
|
||||
if self.text_display: self.text_display.update()
|
||||
if self.of_the_day: self.of_the_day.update(time.time())
|
||||
if self.news_manager: self.news_manager.fetch_news_data()
|
||||
|
||||
# Update NHL managers
|
||||
if self.nhl_live: self.nhl_live.update()
|
||||
@@ -907,6 +923,8 @@ class DisplayController:
|
||||
manager_to_display = self.text_display
|
||||
elif self.current_display_mode == 'of_the_day' and self.of_the_day:
|
||||
manager_to_display = self.of_the_day
|
||||
elif self.current_display_mode == 'news_manager' and self.news_manager:
|
||||
manager_to_display = self.news_manager
|
||||
elif self.current_display_mode == 'nhl_recent' and self.nhl_recent:
|
||||
manager_to_display = self.nhl_recent
|
||||
elif self.current_display_mode == 'nhl_upcoming' and self.nhl_upcoming:
|
||||
@@ -979,6 +997,8 @@ class DisplayController:
|
||||
manager_to_display.display() # Assumes internal clearing
|
||||
elif self.current_display_mode == 'of_the_day':
|
||||
manager_to_display.display(force_clear=self.force_clear)
|
||||
elif self.current_display_mode == 'news_manager':
|
||||
manager_to_display.display_news()
|
||||
elif self.current_display_mode == 'nfl_live' and self.nfl_live:
|
||||
self.nfl_live.display(force_clear=self.force_clear)
|
||||
elif self.current_display_mode == 'ncaa_fb_live' and self.ncaa_fb_live:
|
||||
|
||||
Reference in New Issue
Block a user