mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
Walked the README and docs/ tree against current code and fixed several
real bugs and many stale references. Highlights:
User-facing
- README.md: web interface install instructions referenced
install_web_service.sh at the repo root, but it actually lives at
scripts/install/install_web_service.sh.
- docs/GETTING_STARTED.md: every web UI port reference said 5050, but
the real server in web_interface/start.py:123 binds 5000. Same bug
was duplicated in docs/TROUBLESHOOTING.md (17 occurrences). Fixed
both.
- docs/GETTING_STARTED.md: rewrote tab-by-tab instructions. The doc
referenced "Plugin Store", "Plugin Management", "Sports Configuration",
"Durations", and "Font Management" tabs - none of which exist. Real
tabs (verified in web_interface/templates/v3/base.html) are: Overview,
General, WiFi, Schedule, Display, Config Editor, Fonts, Logs, Cache,
Operation History, Plugin Manager (+ per-plugin tabs).
- docs/GETTING_STARTED.md: removed references to a "Test Display"
button (doesn't exist) and "Show Now" / "Stop" plugin buttons. Real
controls are "Run On-Demand" / "Stop On-Demand" inside each plugin's
tab (partials/plugin_config.html:792).
- docs/TROUBLESHOOTING.md: removed dead reference to
troubleshoot_weather.sh (doesn't exist anywhere in the repo); weather
is now a plugin in ledmatrix-plugins.
Developer-facing
- docs/PLUGIN_API_REFERENCE.md: documented draw_image() doesn't exist
on DisplayManager. Real plugins paste onto display_manager.image
directly (verified in src/base_classes/{baseball,basketball,football,
hockey}.py). Replaced with the canonical pattern.
- docs/PLUGIN_API_REFERENCE.md: documented cache_manager.delete() doesn't
exist. Real method is clear_cache(key=None). Updated the section.
- docs/PLUGIN_API_REFERENCE.md: added 10 missing BasePlugin methods that
the doc never mentioned: dynamic-duration hooks, live-priority hooks,
and the full Vegas-mode interface.
- docs/PLUGIN_DEVELOPMENT_GUIDE.md: same draw_image fix.
- docs/DEVELOPMENT.md: corrected the "Plugin Submodules" section. Plugins
are NOT git submodules - .gitmodules only contains
rpi-rgb-led-matrix-master. Plugins are installed at runtime into the
plugins directory configured by plugin_system.plugins_directory
(default plugin-repos/). Both internal links in this doc were also
broken (missing relative path adjustment).
- docs/HOW_TO_RUN_TESTS.md: removed pytest-timeout from install line
(not in requirements.txt) and corrected the test/integration/ path
(real integration tests are at test/web_interface/integration/).
Replaced the fictional file structure diagram with the real one.
- docs/EMULATOR_SETUP_GUIDE.md: clone URL was a placeholder; default
pixel_size was documented as 16 but emulator_config.json ships with 5.
Index
- docs/README.md: rewrote. Old index claimed "16-17 files after
consolidation" but docs/ actually has 38 .md files. Four were missing
from the index entirely (CONFIG_DEBUGGING, DEV_PREVIEW,
PLUGIN_ERROR_HANDLING, STARLARK_APPS_GUIDE). Trimmed the navel-gazing
consolidation/statistics sections.
Out of scope but worth flagging:
- src/plugin_system/resource_monitor.py:343 and src/common/api_helper.py:287
call cache_manager.delete(key) but no such method exists on
CacheManager. Both call sites would AttributeError at runtime if hit.
Not fixed in this docs PR - either add a delete() shim or convert
callers to clear_cache().
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
424 lines
8.9 KiB
Markdown
424 lines
8.9 KiB
Markdown
# LEDMatrix Emulator Setup Guide
|
||
|
||
## Overview
|
||
|
||
The LEDMatrix emulator allows you to run and test LEDMatrix displays on your computer without requiring physical LED matrix hardware. This is perfect for development, testing, and demonstration purposes.
|
||
|
||
## Table of Contents
|
||
|
||
1. [Prerequisites](#prerequisites)
|
||
2. [Installation](#installation)
|
||
3. [Configuration](#configuration)
|
||
4. [Running the Emulator](#running-the-emulator)
|
||
5. [Display Adapters](#display-adapters)
|
||
6. [Troubleshooting](#troubleshooting)
|
||
7. [Advanced Configuration](#advanced-configuration)
|
||
|
||
## Prerequisites
|
||
|
||
### System Requirements
|
||
- Python 3.7 or higher
|
||
- Windows, macOS, or Linux
|
||
- At least 2GB RAM (4GB recommended)
|
||
- Internet connection for plugin downloads
|
||
|
||
### Required Software
|
||
- Python 3.7+
|
||
- pip (Python package manager)
|
||
- Git (for plugin management)
|
||
|
||
## Installation
|
||
|
||
### 1. Clone the Repository
|
||
|
||
```bash
|
||
git clone --recurse-submodules https://github.com/ChuckBuilds/LEDMatrix.git
|
||
cd LEDMatrix
|
||
```
|
||
|
||
> The emulator does **not** require building the
|
||
> `rpi-rgb-led-matrix-master` submodule (it uses `RGBMatrixEmulator`
|
||
> instead), so `--recurse-submodules` is optional here. Run it anyway if
|
||
> you also want to test the real-hardware code path.
|
||
|
||
### 2. Install Emulator Dependencies
|
||
|
||
Install the emulator-specific requirements:
|
||
|
||
```bash
|
||
pip install -r requirements-emulator.txt
|
||
```
|
||
|
||
This installs:
|
||
- `RGBMatrixEmulator` - The core emulation library
|
||
- Additional dependencies for display adapters
|
||
|
||
### 3. Install Standard Dependencies
|
||
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
## Configuration
|
||
|
||
### 1. Emulator Configuration File
|
||
|
||
The emulator uses `emulator_config.json` for configuration. Here's the
|
||
default configuration as it ships in the repo:
|
||
|
||
```json
|
||
{
|
||
"pixel_outline": 0,
|
||
"pixel_size": 5,
|
||
"pixel_style": "square",
|
||
"pixel_glow": 6,
|
||
"display_adapter": "pygame",
|
||
"icon_path": null,
|
||
"emulator_title": null,
|
||
"suppress_font_warnings": false,
|
||
"suppress_adapter_load_errors": false,
|
||
"browser": {
|
||
"_comment": "For use with the browser adapter only.",
|
||
"port": 8888,
|
||
"target_fps": 24,
|
||
"fps_display": false,
|
||
"quality": 70,
|
||
"image_border": true,
|
||
"debug_text": false,
|
||
"image_format": "JPEG"
|
||
},
|
||
"log_level": "info"
|
||
}
|
||
```
|
||
|
||
### 2. Configuration Options
|
||
|
||
| Option | Description | Default | Values |
|
||
|--------|-------------|---------|--------|
|
||
| `pixel_outline` | Pixel border thickness | 0 | 0-5 |
|
||
| `pixel_size` | Size of each pixel | 5 | 1-64 (8–16 is typical for testing) |
|
||
| `pixel_style` | Pixel shape | "square" | "square", "circle" |
|
||
| `pixel_glow` | Glow effect intensity | 6 | 0-20 |
|
||
| `display_adapter` | Display backend | "pygame" | "pygame", "browser" |
|
||
| `emulator_title` | Window title | null | Any string |
|
||
| `suppress_font_warnings` | Hide font warnings | false | true/false |
|
||
| `suppress_adapter_load_errors` | Hide adapter errors | false | true/false |
|
||
|
||
### 3. Browser Adapter Configuration
|
||
|
||
When using the browser adapter, additional options are available:
|
||
|
||
| Option | Description | Default |
|
||
|--------|-------------|---------|
|
||
| `port` | Web server port | 8888 |
|
||
| `target_fps` | Target frames per second | 24 |
|
||
| `fps_display` | Show FPS counter | false |
|
||
| `quality` | Image compression quality | 70 |
|
||
| `image_border` | Show image border | true |
|
||
| `debug_text` | Show debug information | false |
|
||
| `image_format` | Image format | "JPEG" |
|
||
|
||
## Running the Emulator
|
||
|
||
### 1. Set Environment Variable
|
||
|
||
Enable emulator mode by setting the `EMULATOR` environment variable:
|
||
|
||
**Windows (Command Prompt):**
|
||
```cmd
|
||
set EMULATOR=true
|
||
python run.py
|
||
```
|
||
|
||
**Windows (PowerShell):**
|
||
```powershell
|
||
$env:EMULATOR="true"
|
||
python run.py
|
||
```
|
||
|
||
**Linux/macOS:**
|
||
```bash
|
||
export EMULATOR=true
|
||
python3 run.py
|
||
```
|
||
|
||
### 2. Alternative: Direct Python Execution
|
||
|
||
You can also run the emulator directly:
|
||
|
||
```bash
|
||
EMULATOR=true python3 run.py
|
||
```
|
||
|
||
### 3. Verify Emulator Mode
|
||
|
||
When running in emulator mode, you should see:
|
||
- A window displaying the LED matrix simulation
|
||
- Console output indicating emulator mode
|
||
- No hardware initialization errors
|
||
|
||
## Display Adapters
|
||
|
||
LEDMatrix supports two display adapters for the emulator:
|
||
|
||
### 1. Pygame Adapter (Default)
|
||
|
||
The pygame adapter provides a native desktop window with real-time display.
|
||
|
||
**Features:**
|
||
- Real-time rendering
|
||
- Keyboard controls
|
||
- Window resizing
|
||
- High performance
|
||
|
||
**Configuration:**
|
||
```json
|
||
{
|
||
"display_adapter": "pygame",
|
||
"pixel_size": 16,
|
||
"pixel_style": "square"
|
||
}
|
||
```
|
||
|
||
**Keyboard Controls:**
|
||
- `ESC` - Exit emulator
|
||
- `F11` - Toggle fullscreen
|
||
- `+/-` - Zoom in/out
|
||
- `R` - Reset zoom
|
||
|
||
### 2. Browser Adapter
|
||
|
||
The browser adapter runs a web server and displays the matrix in a web browser.
|
||
|
||
**Features:**
|
||
- Web-based interface
|
||
- Remote access capability
|
||
- Mobile-friendly
|
||
- Screenshot capture
|
||
|
||
**Configuration:**
|
||
```json
|
||
{
|
||
"display_adapter": "browser",
|
||
"browser": {
|
||
"port": 8888,
|
||
"target_fps": 24,
|
||
"quality": 70
|
||
}
|
||
}
|
||
```
|
||
|
||
**Usage:**
|
||
1. Start the emulator with browser adapter
|
||
2. Open browser to `http://localhost:8888`
|
||
3. View the LED matrix display
|
||
|
||
## Troubleshooting
|
||
|
||
### Common Issues
|
||
|
||
#### 1. "ModuleNotFoundError: No module named 'RGBMatrixEmulator'"
|
||
|
||
**Solution:**
|
||
```bash
|
||
pip install RGBMatrixEmulator
|
||
```
|
||
|
||
#### 2. Pygame Window Not Opening
|
||
|
||
**Possible Causes:**
|
||
- Missing pygame installation
|
||
- Display server issues (Linux)
|
||
- Graphics driver problems
|
||
|
||
**Solutions:**
|
||
```bash
|
||
# Install pygame
|
||
pip install pygame
|
||
|
||
# For Linux, ensure X11 is running
|
||
echo $DISPLAY
|
||
|
||
# For WSL, install X server
|
||
# Windows: Install VcXsrv or Xming
|
||
```
|
||
|
||
#### 3. Browser Adapter Not Working
|
||
|
||
**Check:**
|
||
- Port 8888 is available
|
||
- Firewall allows connections
|
||
- Browser can access localhost
|
||
|
||
**Solutions:**
|
||
```bash
|
||
# Check if port is in use
|
||
netstat -an | grep 8888
|
||
|
||
# Try different port in config
|
||
"port": 8889
|
||
```
|
||
|
||
#### 4. Performance Issues
|
||
|
||
**Optimizations:**
|
||
- Reduce `pixel_size` in config
|
||
- Lower `target_fps` for browser adapter
|
||
- Close other applications
|
||
- Use pygame adapter for better performance
|
||
|
||
### Debug Mode
|
||
|
||
Enable debug logging:
|
||
|
||
```json
|
||
{
|
||
"log_level": "debug",
|
||
"suppress_font_warnings": false,
|
||
"suppress_adapter_load_errors": false
|
||
}
|
||
```
|
||
|
||
## Advanced Configuration
|
||
|
||
### 1. Custom Display Dimensions
|
||
|
||
Modify the display dimensions in your main config:
|
||
|
||
```json
|
||
{
|
||
"display": {
|
||
"hardware": {
|
||
"rows": 32,
|
||
"cols": 64,
|
||
"chain_length": 2
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### 2. Plugin Development
|
||
|
||
For plugin development with the emulator:
|
||
|
||
```bash
|
||
# Enable emulator mode
|
||
export EMULATOR=true
|
||
|
||
# Run with specific plugin
|
||
python run.py --plugin my-plugin
|
||
|
||
# Debug mode
|
||
python run.py --debug
|
||
```
|
||
|
||
### 3. Performance Tuning
|
||
|
||
**For High-Resolution Displays:**
|
||
```json
|
||
{
|
||
"pixel_size": 8,
|
||
"pixel_glow": 2,
|
||
"browser": {
|
||
"target_fps": 15,
|
||
"quality": 50
|
||
}
|
||
}
|
||
```
|
||
|
||
**For Low-End Systems:**
|
||
```json
|
||
{
|
||
"pixel_size": 12,
|
||
"pixel_glow": 0,
|
||
"browser": {
|
||
"target_fps": 10,
|
||
"quality": 30
|
||
}
|
||
}
|
||
```
|
||
|
||
### 4. Integration with Web Interface
|
||
|
||
The emulator can work alongside the web interface:
|
||
|
||
```bash
|
||
# Terminal 1: Start emulator
|
||
export EMULATOR=true
|
||
python run.py
|
||
|
||
# Terminal 2: Start web interface
|
||
python web_interface/app.py
|
||
```
|
||
|
||
Access the web interface at `http://localhost:5000` while the emulator runs.
|
||
|
||
## Best Practices
|
||
|
||
### 1. Development Workflow
|
||
|
||
1. **Start with emulator** for initial development
|
||
2. **Test plugins** using emulator mode
|
||
3. **Validate configuration** before hardware deployment
|
||
4. **Use browser adapter** for remote testing
|
||
|
||
### 2. Plugin Testing
|
||
|
||
```bash
|
||
# Test specific plugin
|
||
export EMULATOR=true
|
||
python run.py --plugin clock-simple
|
||
|
||
# Test all plugins
|
||
export EMULATOR=true
|
||
python run.py --test-plugins
|
||
```
|
||
|
||
### 3. Configuration Management
|
||
|
||
- Keep `emulator_config.json` in version control
|
||
- Use different configs for different environments
|
||
- Document custom configurations
|
||
|
||
## Examples
|
||
|
||
### Basic Clock Display
|
||
|
||
```bash
|
||
# Start emulator with clock
|
||
export EMULATOR=true
|
||
python run.py
|
||
```
|
||
|
||
### Sports Scores
|
||
|
||
```bash
|
||
# Configure for sports display
|
||
# Edit config/config.json to enable sports plugins
|
||
export EMULATOR=true
|
||
python run.py
|
||
```
|
||
|
||
### Custom Text Display
|
||
|
||
```bash
|
||
# Use text display plugin
|
||
export EMULATOR=true
|
||
python run.py --plugin text-display --text "Hello World"
|
||
```
|
||
|
||
## Support
|
||
|
||
For additional help:
|
||
|
||
1. **Check the logs** - Enable debug mode for detailed output
|
||
2. **Review configuration** - Ensure all settings are correct
|
||
3. **Test with minimal config** - Start with default settings
|
||
4. **Community support** - Check GitHub issues and discussions
|
||
|
||
## Conclusion
|
||
|
||
The LEDMatrix emulator provides a powerful way to develop, test, and demonstrate LED matrix displays without physical hardware. With support for multiple display adapters and comprehensive configuration options, it's an essential tool for LEDMatrix development and deployment.
|
||
|
||
For more information, see the main [README.md](../README.md) and other documentation in the `docs/` directory.
|