From 7b64f10dade0acc2ec183421596ce83a5fb2c4fd Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 25 May 2025 18:08:20 -0500 Subject: [PATCH] Revert "slow music debugging so I can read it" This reverts commit 830b14cb6152b504b8e16a10d49a5d140eb9d9d1. --- src/display_manager.py | 2 +- src/music_manager.py | 39 +++++++++++---------------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/display_manager.py b/src/display_manager.py index c2bbccce..f85e7acc 100644 --- a/src/display_manager.py +++ b/src/display_manager.py @@ -173,7 +173,7 @@ class DisplayManager: logger.info("Press Start 2P font loaded successfully") # Use the same font for small text, just at a smaller size - self.small_font = ImageFont.truetype("assets/fonts/PressStart2P-Regular.ttf", 5) + self.small_font = ImageFont.truetype("assets/fonts/PressStart2P-Regular.ttf", 8) logger.info("Press Start 2P small font loaded successfully") # Load 5x7 BDF font for calendar events diff --git a/src/music_manager.py b/src/music_manager.py index f41fc12e..f2904aad 100644 --- a/src/music_manager.py +++ b/src/music_manager.py @@ -41,8 +41,6 @@ class MusicManager: self.preferred_source = "auto" # Default self.stop_event = threading.Event() self.track_info_lock = threading.Lock() # Added lock - self._last_periodic_debug_log_time = 0 - self.PERIODIC_DEBUG_LOG_INTERVAL = 1.0 # Log roughly every 1 second # Display related attributes moved from DisplayController self.album_art_image = None @@ -440,12 +438,6 @@ class MusicManager: self.display_manager.clear() self.activate_music_display() - can_log_debug_this_call = False - current_time_for_log = time.time() - if current_time_for_log - self._last_periodic_debug_log_time > self.PERIODIC_DEBUG_LOG_INTERVAL: - can_log_debug_this_call = True - self._last_periodic_debug_log_time = current_time_for_log - with self.track_info_lock: current_display_info = self.current_track_info.copy() if self.current_track_info else None # We also need self.last_album_art_url and self.album_art_image under the same lock if they are read here and written elsewhere @@ -455,12 +447,9 @@ class MusicManager: local_last_album_art_url = self.last_album_art_url local_album_art_image = self.album_art_image - if can_log_debug_this_call: - logger.debug(f"[MusicManager.display] Current display info before check: {current_display_info}") - + logger.debug(f"[MusicManager.display] Current display info before check: {current_display_info}") if not current_display_info or current_display_info.get('title') == 'Nothing Playing': - if can_log_debug_this_call: - logger.debug("[MusicManager.display] Entered 'Nothing Playing' block.") + logger.debug("[MusicManager.display] Entered 'Nothing Playing' block.") if not hasattr(self, '_last_nothing_playing_log_time') or \ time.time() - getattr(self, '_last_nothing_playing_log_time', 0) > 30: logger.info("Music Screen (MusicManager): Nothing playing or info explicitly 'Nothing Playing'.") @@ -468,22 +457,17 @@ class MusicManager: if not force_clear: self.display_manager.clear() - if can_log_debug_this_call: - logger.debug("[MusicManager.display] Display cleared (not force_clear path).") + logger.debug("[MusicManager.display] Display cleared (not force_clear path).") - if can_log_debug_this_call: - logger.debug(f"[MusicManager.display] Font for 'Nothing Playing': {self.display_manager.small_font}, Type: {type(self.display_manager.small_font)}") - text_width = self.display_manager.get_text_width("Nothing Playing", self.display_manager.small_font) - if can_log_debug_this_call: - logger.debug(f"[MusicManager.display] Calculated text_width for 'Nothing Playing': {text_width}") + logger.debug(f"[MusicManager.display] Font for 'Nothing Playing': {self.display_manager.regular_font}, Type: {type(self.display_manager.regular_font)}") + text_width = self.display_manager.get_text_width("Nothing Playing", self.display_manager.regular_font) + logger.debug(f"[MusicManager.display] Calculated text_width for 'Nothing Playing': {text_width}") x_pos = (self.display_manager.matrix.width - text_width) // 2 - y_pos = (self.display_manager.matrix.height // 2) - 4 # Adjusted for typical small font height - if can_log_debug_this_call: - logger.debug(f"[MusicManager.display] Drawing 'Nothing Playing' at x={x_pos}, y={y_pos}") - self.display_manager.draw_text("Nothing Playing", x=x_pos, y=y_pos, font=self.display_manager.small_font) + y_pos = (self.display_manager.matrix.height // 2) - 4 + logger.debug(f"[MusicManager.display] Drawing 'Nothing Playing' at x={x_pos}, y={y_pos}") + self.display_manager.draw_text("Nothing Playing", x=x_pos, y=y_pos, font=self.display_manager.regular_font) self.display_manager.update_display() - if can_log_debug_this_call: - logger.debug("[MusicManager.display] 'Nothing Playing' text drawn and display updated.") + logger.debug("[MusicManager.display] 'Nothing Playing' text drawn and display updated.") with self.track_info_lock: # Protect writes to shared state self.scroll_position_title = 0 @@ -494,8 +478,7 @@ class MusicManager: # self.last_album_art_url = None # Keep last_album_art_url so we don't re-fetch if it was a brief flicker return - if can_log_debug_this_call: - logger.debug("[MusicManager.display] Proceeding to display actual music info.") + logger.debug("[MusicManager.display] Proceeding to display actual music info.") # If we've reached here, it means we are about to display actual music info. if not self.is_music_display_active: self.activate_music_display()