A C++ application to control LED matrix displays with various scene effects, image display capabilities, and a REST API interface.
- REST API server for remote control
- Plugin system for extensible scenes and effects
- Various built-in scenes:
- Image display
- Rain effect
- Watermelon plasma
- Wave effect
- Weather display
- Spotify integration
- Sparks effect
- Ping pong game
- Tetris
- Maze generator
- Starfield
- Metablob effect
- Fire effect
- Preset management system
- Remote image loading and processing
- Hardware abstraction for LED matrix control
The main application that controls the LED matrix and provides the REST API. It handles:
- Scene rendering and animation
- Plugin loading and management
- Hardware interfacing with LED matrices
- REST API endpoints for remote control
- Configuration persistence
A mobile application for controlling the LED matrix remotely. Located in the react-native
directory.
- Scene selection and configuration
- Real-time control of matrix displays
- Preset management
- Image uploading
This project is designed to work with:
- Raspberry Pi (3B+ or 4 recommended)
- RGB LED matrix panels with HUB75 interface
- Appropriate power supply for your matrix (5V with sufficient amperage)
- Adafruit RGB Matrix Bonnet or similar HAT/Bonnet (recommended for stable performance)
The application supports various matrix sizes and chaining configurations:
- Single panels (typically 32x32, 64x32, or 64x64)
- Multiple panels chained together horizontally and/or vertically
- Configure your matrix dimensions in the command line options or configuration file
- CMake 3.5 or higher
- C++23 compatible compiler
jinja2
Python package (can be installed by runningapt install python3-jinja2 -y
)- vcpkg package manager
- React Native development environment (for the mobile app)
- GraphicsMagick and development headers (
apt install libgraphicsmagick1-dev
)
Note: Building this project on the RPI can be slow, cross-compilation is advised: Guide
- Install vcpkg following instructions at https://github.com/Microsoft/vcpkg
- Configure CMake:
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=[path_to_vcpkg]/scripts/buildsystems/vcpkg.cmake
- Build:
cmake --build build
- Install (optional):
cmake --install build
To build with emulator support (using SDL2), use the provided CMake preset:
# Configure and build with emulator support using the preset
cmake --preset=emulator
cmake --build emulator_build
This will automatically enable the "emulator" feature in vcpkg and include SDL2 as a dependency.
- Navigate to the React Native app directory:
cd react-native
- Install dependencies:
npm install
- Run the app:
npm run dev:android # Run Android
npm run dev:ios # Run on iOS
Run the application with:
sudo ./led-matrix-controller [options]
Common options:
--led-rows=32
: Number of rows per panel--led-cols=64
: Number of columns per panel--led-chain=1
: Number of daisy-chained panels--led-parallel=1
: Number of parallel chains--led-brightness=100
: Set brightness (0-100)--led-gpio-mapping=adafruit-hat
: GPIO mapping for your hardware
The application uses a config.json
file in its root directory for persistent settings:
- Scene presets
- Default configurations
- API settings
- Plugin configurations
This file is automatically created if it doesn't exist.
The application uses spdlog for logging. You can control the log level using the SPDLOG_LEVEL
environment variable:
SPDLOG_LEVEL=debug ./led-matrix-controller
Available log levels:
trace
: Most detailed loggingdebug
: Debug informationinfo
: General informationwarn
: Warningserror
: Errorscritical
: Critical errorsoff
: Disable logging
All logs are output to the console.
The REST API is available at http://<device-ip>:8080/
.
Main endpoints:
GET /get_curr
: Get current scene informationGET /list_scenes
: List all available scenesGET /list_providers
: List all available image providersGET /set_preset?id=<preset_id>
: Switch to a specific presetGET /presets
: List saved presets (with ?id=<preset_id> to get specific preset)GET /list_presets
: Get detailed information about all presetsPOST /preset?id=<preset_id>
: Create or update a presetPOST /add_preset?id=<preset_id>
: Add a new presetDELETE /preset?id=<preset_id>
: Delete a presetGET /list
: List available imagesGET /image?url=<url>
: Fetch and process remote imageGET /toggle
: Toggle the display on/offGET /skip
: Skip the current sceneGET /set_enabled?enabled=<true|false>
: Enable or disable the displayGET /status
: Get current matrix status
The application also serves static files from the /web/
directory.
- Matrix flickering: Check your power supply rating. LED matrices require substantial current.
- Permission errors: The application needs to be run with sudo to access GPIO pins.
- Slow performance: Consider overclocking your Raspberry Pi if using complex scenes.
- Can't connect to API: Check firewall settings and ensure the correct port is open.
- Create a new directory in
plugins/
for your plugin - Create the following basic structure:
plugins/
└── YourPlugin/
├── CMakeLists.txt
├── YourPlugin.cpp
├── YourPlugin.h
└── scenes/
├── YourScene.cpp
└── YourScene.h
Your plugin must implement:
- A main plugin class inheriting from
BasicPlugin
- One or more scene classes inheriting from
Scenes::Scene
- Scene wrapper classes for scene instantiation
Example plugin header:
class MyPlugin : public BasicPlugin {
public:
MyPlugin();
vector<std::unique_ptr<SceneWrapper, void (*)(Plugins::SceneWrapper *)>> create_scenes() override;
vector<std::unique_ptr<ImageProviderWrapper, void(*)(ImageProviderWrapper*)>> create_image_providers() override;
};
Scenes can define configurable properties using the property system:
// In your scene class
Property<float> mySpeed{"speed", 1.0f}; // Default value 1.0
Property<int> myColor{"color", 0xFF0000}; // Default color red
// Register in register_properties()
void register_properties() override {
add_property(mySpeed);
add_property(myColor);
}
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.