From 4d1c95eded2a99d237eaf86cba21ca56cc32c05d Mon Sep 17 00:00:00 2001 From: Chuck Date: Sun, 1 Mar 2026 19:12:58 -0500 Subject: [PATCH] feat(music): Add layout customization and align font defaults - Add y_percent to title_text, artist_text, album_text in config schema (defaults 0.03, 0.34, 0.60) to let users adjust vertical positions and fix overlap with progress bar on small displays - Update manager to read layout percents from customization config - Clarify artist/album font defaults match display manager 5x7 font - Bump plugin version to 1.0.4 and sync registry Made-with: Cursor --- plugins.json | 6 +-- plugins/ledmatrix-music/config_schema.json | 43 ++++++++++++++++++---- plugins/ledmatrix-music/manager.py | 36 +++++++++++++----- plugins/ledmatrix-music/manifest.json | 9 ++++- 4 files changed, 72 insertions(+), 22 deletions(-) diff --git a/plugins.json b/plugins.json index 5638bd8..f5807c9 100644 --- a/plugins.json +++ b/plugins.json @@ -1,6 +1,6 @@ { "version": "1.0.0", - "last_updated": "2026-02-26", + "last_updated": "2026-03-01", "plugins": [ { "id": "hello-world", @@ -150,10 +150,10 @@ "plugin_path": "plugins/ledmatrix-music", "stars": 0, "downloads": 0, - "last_updated": "2025-11-05", + "last_updated": "2026-03-01", "verified": true, "screenshot": "", - "latest_version": "1.0.3" + "latest_version": "1.0.4" }, { "id": "calendar", diff --git a/plugins/ledmatrix-music/config_schema.json b/plugins/ledmatrix-music/config_schema.json index 21fc952..0ad0a56 100644 --- a/plugins/ledmatrix-music/config_schema.json +++ b/plugins/ledmatrix-music/config_schema.json @@ -184,7 +184,7 @@ "title_text": { "type": "object", "title": "Track Title", - "description": "Font settings for the track title", + "description": "Font and layout settings for the track title", "properties": { "font": { "type": "string", @@ -207,20 +207,29 @@ "minimum": 4, "maximum": 16, "default": 8 + }, + "y_percent": { + "type": "number", + "title": "Vertical Position", + "description": "Vertical position as fraction of display height (0.0=top, 1.0=bottom). Adjust if elements overlap the progress bar.", + "minimum": 0.0, + "maximum": 1.0, + "default": 0.03, + "multipleOf": 0.01 } }, - "x-propertyOrder": ["font", "font_size"], + "x-propertyOrder": ["font", "font_size", "y_percent"], "additionalProperties": false }, "artist_text": { "type": "object", "title": "Artist Name", - "description": "Font settings for the artist name", + "description": "Font and layout settings for the artist name", "properties": { "font": { "type": "string", "title": "Font Family", - "description": "Select the font to use", + "description": "Select the font to use (default matches the display manager 5x7 font)", "enum": [ "PressStart2P-Regular.ttf", "4x6-font.ttf", @@ -238,20 +247,29 @@ "minimum": 4, "maximum": 16, "default": 7 + }, + "y_percent": { + "type": "number", + "title": "Vertical Position", + "description": "Vertical position as fraction of display height (0.0=top, 1.0=bottom). Adjust if elements overlap the progress bar.", + "minimum": 0.0, + "maximum": 1.0, + "default": 0.34, + "multipleOf": 0.01 } }, - "x-propertyOrder": ["font", "font_size"], + "x-propertyOrder": ["font", "font_size", "y_percent"], "additionalProperties": false }, "album_text": { "type": "object", "title": "Album Name", - "description": "Font settings for the album name", + "description": "Font and layout settings for the album name", "properties": { "font": { "type": "string", "title": "Font Family", - "description": "Select the font to use", + "description": "Select the font to use (default matches the display manager 5x7 font)", "enum": [ "PressStart2P-Regular.ttf", "4x6-font.ttf", @@ -269,9 +287,18 @@ "minimum": 4, "maximum": 16, "default": 7 + }, + "y_percent": { + "type": "number", + "title": "Vertical Position", + "description": "Vertical position as fraction of display height (0.0=top, 1.0=bottom). Adjust if elements overlap the progress bar.", + "minimum": 0.0, + "maximum": 1.0, + "default": 0.60, + "multipleOf": 0.01 } }, - "x-propertyOrder": ["font", "font_size"], + "x-propertyOrder": ["font", "font_size", "y_percent"], "additionalProperties": false } }, diff --git a/plugins/ledmatrix-music/manager.py b/plugins/ledmatrix-music/manager.py index 8a331c8..18be0eb 100644 --- a/plugins/ledmatrix-music/manager.py +++ b/plugins/ledmatrix-music/manager.py @@ -950,13 +950,26 @@ def display(self, force_clear: bool = False) -> None: font_artist = self.artist_font if self.artist_font else self.display_manager.bdf_5x7_font font_album = self.album_font if self.album_font else self.display_manager.bdf_5x7_font + # Read per-element layout overrides from customization config. + customization_layout = self.config.get('customization', {}) + title_layout_config = customization_layout.get('title_text', {}) + artist_layout_config = customization_layout.get('artist_text', {}) + album_layout_config = customization_layout.get('album_text', {}) + + def _safe_y_percent(value, fallback): + """Normalize optional y_percent values to 0.0-1.0 range.""" + try: + return max(0.0, min(1.0, float(value))) + except (TypeError, ValueError): + return fallback + + title_y_percent = _safe_y_percent(title_layout_config.get('y_percent', 0.03), 0.03) + artist_y_percent = _safe_y_percent(artist_layout_config.get('y_percent', 0.34), 0.34) + album_y_percent = _safe_y_percent(album_layout_config.get('y_percent', 0.60), 0.60) + # Calculate y positions as percentages of display height for scaling matrix_height = self.display_manager.matrix.height - - # Define positions as percentages (0.0 to 1.0) - these scale with display size - ARTIST_Y_PERCENT = 0.34 # 34% from top - ALBUM_Y_PERCENT = 0.60 # 60% from top - + # Calculate dynamic font heights based on display size # For smaller displays (32px), use smaller line heights # For larger displays, scale up proportionally @@ -972,12 +985,17 @@ def display(self, force_clear: bool = False) -> None: FIXED_BDF_BASELINE_SHIFT = max(6, int(matrix_height * 0.19)) # 19% of height, min 6 # Calculate positions with proper scaling - y_pos_title_top = max(1, int(matrix_height * 0.03)) # 3% from top, min 1px - y_pos_artist_top = int(matrix_height * ARTIST_Y_PERCENT) + FIXED_BDF_BASELINE_SHIFT - y_pos_album_top = int(matrix_height * ALBUM_Y_PERCENT) + FIXED_BDF_BASELINE_SHIFT + y_pos_title_top = max(1, int(matrix_height * title_y_percent)) + y_pos_artist_top = int(matrix_height * artist_y_percent) + FIXED_BDF_BASELINE_SHIFT + y_pos_album_top = int(matrix_height * album_y_percent) + FIXED_BDF_BASELINE_SHIFT # Debug logging for scaling calculations - self.logger.debug(f"MusicPlugin.display: Display scaling - matrix: {matrix_width}x{matrix_height}, album_art: {album_art_size}px, LINE_HEIGHT_BDF: {LINE_HEIGHT_BDF}, positions - title: {y_pos_title_top}, artist: {y_pos_artist_top}, album: {y_pos_album_top}") + self.logger.debug( + f"MusicPlugin.display: Display scaling - matrix: {matrix_width}x{matrix_height}, " + f"album_art: {album_art_size}px, LINE_HEIGHT_BDF: {LINE_HEIGHT_BDF}, " + f"y_percent(title/artist/album)=({title_y_percent:.2f}/{artist_y_percent:.2f}/{album_y_percent:.2f}), " + f"positions - title: {y_pos_title_top}, artist: {y_pos_artist_top}, album: {y_pos_album_top}" + ) # Title scrolling with configurable settings title_config = self.scroll_config['title'] diff --git a/plugins/ledmatrix-music/manifest.json b/plugins/ledmatrix-music/manifest.json index 7965f46..44aa68a 100644 --- a/plugins/ledmatrix-music/manifest.json +++ b/plugins/ledmatrix-music/manifest.json @@ -1,7 +1,7 @@ { "id": "ledmatrix-music", "name": "Music Player - Now Playing", - "version": "1.0.3", + "version": "1.0.4", "description": "Real-time now playing display for Spotify and YouTube Music with album art, scrolling text, and progress bars", "author": "ChuckBuilds", "entry_point": "manager.py", @@ -67,6 +67,11 @@ } ], "versions": [ + { + "version": "1.0.4", + "ledmatrix_min": "2.0.0", + "released": "2026-03-01" + }, { "version": "1.0.3", "ledmatrix_min": "2.0.0", @@ -78,7 +83,7 @@ "released": "2025-01-16" } ], - "last_updated": "2025-11-05", + "last_updated": "2026-03-01", "stars": 0, "downloads": 0, "verified": true,