A flexible and extensible LED matrix display system built with .NET 9, designed to run on Raspberry Pi with RGB LED matrices or in a simulated environment for development and testing.
- 🎨 Rich Visual Effects - Multiple built-in apps with stunning animations and effects
- 🖥️ Simulator Mode - Develop and test apps without physical hardware
- 🔌 Hardware Support - Native support for Raspberry Pi RGB LED matrices via rpi-rgb-led-matrix library
- 🌐 Web API - RESTful API for controlling apps, brightness, and settings
- 🎯 Extensible Architecture - Easy-to-use base classes for creating custom apps
- 🚀 High Performance - Optimized rendering engine with configurable FPS
- 📱 Web Preview - Real-time browser preview in simulator mode
The system includes several pre-built applications:
- Clock (
clock) - Simple digital clock with decorative stars - Animated Clock (
animated-clock) - 7-segment style animated digital clock with smooth transitions
- Rainbow Spiral (
rainbow-spiral) - Mesmerizing rainbow-colored spiral animation - Geometric Patterns (
geometric-patterns) - Rotating triangles, pulsating circles, and rotating squares - Bouncing Balls (
bouncing-balls) - Physics-based bouncing balls with glow effects - DVD Logo (
dvd-logo) - Classic DVD screensaver bounce effect with color changes - Matrix Rain (
matrix-rain) - The Matrix-style falling characters effect - Solid Color (
solid_color) - Simple solid color display
- Weather (
weather) - Display current weather information (requires API configuration) - Spotify (
spotify) - Display currently playing track from Spotify (requires API configuration)
The project is organized into several modules:
- LedMatrixOS - Main application with ASP.NET Core web server
- LedMatrixOS.Core - Core abstractions and rendering engine
IMatrixApp- Interface for creating appsMatrixAppBase- Base class with lifecycle managementRenderEngine- High-performance rendering loopFrameBuffer- Pixel buffer for frame compositionAppManager- App registration and activation
- LedMatrixOS.Apps - Collection of built-in applications
- LedMatrixOS.Hardware.RpiLedMatrix - Raspberry Pi hardware adapter (native bindings to librgbmatrix.so)
- LedMatrixOS.Hardware.Simulator - Simulated display for development
- .NET 9.0 SDK or runtime
- Any platform (Windows, Linux, macOS)
- Raspberry Pi (tested on Pi 3/4)
- .NET 9.0 runtime (ARM)
- RGB LED Matrix panels
- rpi-rgb-led-matrix library installed
- Root privileges (for GPIO access)
git clone https://github.com/benfl3713/LedMatrixOS.git
cd LedMatrixOSdotnet buildEdit src/LedMatrixOS/appsettings.json to configure your matrix:
{
"Urls": "http://*:5005",
"Matrix": {
"Rows": 64,
"Cols": 64,
"HardwareMapping": "adafruit-hat-pwm",
"GpioSlowdown": 4,
"ChainLength": 4,
"PwmBits": 7,
"ShowRefreshRate": true
}
}For simulator mode, add appsettings.Development.json:
{
"Matrix": {
"UseSimulator": true
}
}cd src/LedMatrixOS
dotnet run --environment DevelopmentThen open your browser to http://localhost:5005 to see the web preview interface.
cd src/LedMatrixOS
sudo dotnet run --environment ProductionNote: Root privileges are required for GPIO access on Raspberry Pi.
The application exposes a RESTful API for control:
POST /api/apps/{id}- Activate an app by IDcurl -X POST http://localhost:5005/api/apps/animated-clock
-
GET /api/settings- Get current settings (width, height, brightness)curl http://localhost:5005/api/settings
-
POST /api/settings/brightness/{value}- Set brightness (0-100)curl -X POST http://localhost:5005/api/settings/brightness/50
-
POST /api/settings/fps/{value}- Set target FPS (1-120)curl -X POST http://localhost:5005/api/settings/fps/60
GET /preview- Get current display as PNG (simulator mode only)curl http://localhost:5005/preview -o preview.png
To create your own app, inherit from MatrixAppBase:
using LedMatrixOS.Core;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace LedMatrixOS.Apps;
public sealed class MyCustomApp : MatrixAppBase
{
public override string Id => "my-custom-app";
public override string Name => "My Custom App";
private double _animationTime;
public override void Update(TimeSpan deltaTime, CancellationToken cancellationToken)
{
// Update animation state
_animationTime += deltaTime.TotalSeconds;
}
public override void Render(FrameBuffer frame, CancellationToken cancellationToken)
{
// Option 1: Direct pixel manipulation
for (int y = 0; y < frame.Height; y++)
{
for (int x = 0; x < frame.Width; x++)
{
frame.SetPixel(x, y, new Pixel(255, 0, 0));
}
}
// Option 2: Using ImageSharp (recommended for complex graphics)
using var image = new Image<Rgb24>(frame.Width, frame.Height);
image.Mutate(ctx =>
{
// Draw your graphics here
ctx.Fill(Color.Blue);
});
frame.RenderImage(image);
}
}Apps can override these methods for lifecycle management:
OnActivatedAsync()- Called when app becomes active (initialize resources)Update()- Called every frame to update stateRender()- Called every frame to render outputOnDeactivatedAsync()- Called when app is deactivated (cleanup resources)
For apps that need background work (like fetching data):
public override Task OnActivatedAsync((int height, int width) dimensions, CancellationToken cancellationToken)
{
// Start a background task
RunInBackground(async (ct) =>
{
while (!ct.IsCancellationRequested)
{
// Fetch data, etc.
await Task.Delay(TimeSpan.FromMinutes(5), ct);
}
});
return base.OnActivatedAsync(dimensions, cancellationToken);
}Add your app to BuiltInApps.GetAll() in src/LedMatrixOS.Apps/Apps.cs:
public static IEnumerable<Type> GetAll()
{
yield return typeof(MyCustomApp);
// ... other apps
}
>>>>>>> mainConfigure in appsettings.json:
| Setting | Description | Default |
|---|---|---|
Rows |
Number of rows per panel | 64 |
Cols |
Number of columns per panel | 64 |
HardwareMapping |
Hardware mapping type | adafruit-hat-pwm |
GpioSlowdown |
GPIO slowdown factor (1-4) | 4 |
ChainLength |
Number of chained panels | 4 |
PwmBits |
PWM bits (1-11, lower = faster) | 7 |
ShowRefreshRate |
Show refresh rate on console | true |
Matrix:UseSimulator- Set totruefor simulator modeUrls- HTTP endpoint URL (default:http://*:5005)
LedMatrixOS/
├── src/
│ ├── LedMatrixOS/ # Main web application
│ │ ├── Program.cs # Entry point
│ │ ├── appsettings.json # Configuration
│ │ └── wwwroot/
│ │ └── index.html # Web preview UI
│ ├── LedMatrixOS.Core/ # Core engine
│ │ └── Class1.cs # Core abstractions
│ ├── LedMatrixOS.Apps/ # Built-in apps
│ ├── LedMatrixOS.Hardware.RpiLedMatrix/ # Pi hardware
│ └── LedMatrixOS.Hardware.Simulator/ # Simulator
├── LedMatrixOS.sln # Solution file
└── Directory.Build.props # Common build settings
# Build entire solution
dotnet build
# Build specific project
dotnet build src/LedMatrixOS/LedMatrixOS.csproj
# Build for release
dotnet build -c ReleaseThe simulator mode is perfect for testing apps without hardware:
- Set
Matrix:UseSimulatortotruein configuration - Run the application
- Open
http://localhost:5005in your browser - Use the web UI to switch between apps and adjust settings
Make sure the rpi-rgb-led-matrix library is installed and accessible:
sudo apt-get update
sudo apt-get install librgbmatrix-devLED matrix control requires root privileges:
sudo dotnet runTry adjusting these settings in appsettings.json:
- Increase
GpioSlowdown(values 1-4) - Decrease
PwmBitsfor faster refresh - Check power supply (LED matrices need significant power)
Make sure you're running in Development mode:
dotnet run --environment DevelopmentContributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-app) - Commit your changes (
git commit -m 'Add amazing app') - Push to the branch (
git push origin feature/amazing-app) - Open a Pull Request
This project is provided as-is for educational and personal use.
- Built with .NET 9
- Uses SixLabors.ImageSharp for graphics
- Hardware support via rpi-rgb-led-matrix by Henner Zeller
- Inspired by the LED matrix community
For issues, questions, or suggestions, please open an issue on GitHub.
