mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-10 17:16:36 +00:00
Each scroller already logs its own stats line, but in different formats, per source, and Vegas logs a healthy window only at DEBUG. None of it answers the question a release has to answer on each rig: over a long run, how often did a moving frame reach the panel late? Every frame reaches the panel through DisplayManager.update_display, so it is timed there once, whoever drew it: the blit (SetImage), the vsync wait, and the interval since the previous frame. The render thread only appends a tuple. A worker thread aggregates cumulative counters and histograms and rewrites /dev/shm/ledmatrix_frame_stats.json every 10s (RAM, so no SD wear). A frame due after `hold` refreshes that lands one or more refreshes later is "late": the panel repeated the previous frame, a visible hitch. Gaps of 250ms+ inside a scroll are "freezes" (recomposes, handovers, blocking calls), counted separately so one handover does not read as 40 missed refreshes. Static frames, the first frame of a scroll and gaps between scrolls are not timed. The refresh period is estimated from the frames themselves. scripts/frame_soak.py runs next to the service as any user, diffs two snapshots over a run (default 10 minutes), optionally keeps the web preview's viewer marker fresh, and exits non-zero above 0.1% late frames. It also reports whether the loaded rgbmatrix binding releases the GIL. Documented under "Soaking a rig" in docs/SCROLL_PERFORMANCE.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.6 KiB
4.6 KiB
LEDMatrix
Project Structure
src/plugin_system/— Plugin loader, manager, store manager, base plugin classweb_interface/— Flask web UI (blueprints, templates, static JS)config/config.json— User plugin configuration (persists across plugin reinstalls)plugin-repos/— Default plugin install directory used by the Plugin Store, set byplugin_system.plugins_directoryinconfig.json(default perconfig/config.template.json). Not gitignored.plugins/— Legacy/dev plugin location. Gitignored (plugins/*). Used byscripts/dev/dev_plugin_setup.shfor symlinks. The plugin loader does NOT fall back to it —PluginManager.discover_plugins()(src/plugin_system/plugin_manager.py) scans only the configured directory. Fallbacks exist in two narrower places: store operations (StoreManager._find_plugin_path()instore_manager.py) and schema lookup (SchemaManager.get_schema_path()inschema_manager.py, which probesplugins/beforeplugin-repos/).
Plugin System
- Plugins inherit from
BasePlugininsrc/plugin_system/base_plugin.py - Required abstract methods:
update(),display(force_clear=False) - Each plugin needs:
manifest.json,config_schema.json,manager.py,requirements.txt - Plugin instantiation args:
plugin_id, config, display_manager, cache_manager, plugin_manager - Config schemas use JSON Schema Draft-7
- Display dimensions: always read dynamically from
self.display_manager.width/height— notdisplay_manager.matrix.width/height, becausematrixisNonewhen hardware init fails (the properties fall back to the canvas size) - Secrets: namespaced by plugin id in
config/config_secrets.json, declared via"x-secret": truein the plugin's config schema, and deep-merged into the plugin's config dict at load time — plugins read them with plainconfig.get(...), never a separate accessor
Dev Workflow
- Link a plugin for development:
./scripts/dev/dev_plugin_setup.sh link-github <name>clones theledmatrix-pluginsmonorepo into~/.ledmatrix-dev-plugins/and links itsplugins/<name>under the manifest id (add a repo URL for a plugin with its own repo; orlink <name> <path>); symlinks land inplugins/— setplugin_system.plugins_directorytopluginsso discovery picks them up. Fork/location overrides:dev_plugins.json(fromdev_plugins.json.example) - Browser preview without the display loop:
python3 scripts/dev_server.py→ http://localhost:5001 - Full display in emulator mode:
python3 run.py -e(orEMULATOR=true python3 run.py) - Validate one plugin headlessly:
python3 scripts/check_plugin.py --plugin <id> - Soak a rig for frame timing (on the Pi, service running):
python3 scripts/frame_soak.py --preview— late-frame rate across every scroller; seedocs/SCROLL_PERFORMANCE.md
Plugin Store Architecture
- Official plugins live in the
ledmatrix-pluginsmonorepo (not individual repos) - Plugin repo naming convention:
ledmatrix-<plugin-id>(e.g.,ledmatrix-football-scoreboard) plugins.jsonregistry athttps://raw.githubusercontent.com/ChuckBuilds/ledmatrix-plugins/main/plugins.json- Store manager (
src/plugin_system/store_manager.py) handles install/update/uninstall - Monorepo plugins are installed via ZIP extraction (no
.gitdirectory) - Update detection for monorepo plugins uses version comparison (manifest version vs registry latest_version)
- Plugin configs stored in
config/config.json, NOT in plugin directories — safe across reinstalls - Third-party plugins can use their own repo URL with empty
plugin_path
Common Pitfalls
- paho-mqtt 2.x needs
callback_api_version=mqtt.CallbackAPIVersion.VERSION1for v1 compat - BasePlugin uses
get_logger()fromsrc.logging_config, not standardlogging.getLogger() DisplayManagerhas nodraw_image()— paste onto the PIL image directly:self.display_manager.image.paste(img, (x, y))thenupdate_display()(use a mask for transparency:image.paste(rgba, (x, y), rgba))- When modifying a plugin in the monorepo, you MUST bump
versionin itsmanifest.jsonand runpython update_registry.py— otherwise users won't receive the update src/pi5_matrix_support.pyhardcodes what the pinnedrpi-rgb-led-matrix-mastercan drive on a Raspberry Pi 5 (Rp1PioConfigSupported()inlib/rp1/rp1_pio_backend.cc). Re-check it whenever the submodule is bumped: a stale rule blocks Pi 5 settings the new library supports, and a missing one lets the display service crash-loop.src/matrix_support.pyholds the same kind of rules for every board (rows, chain length, mapping names, parallel per mapping) and needs the same re-check