This project is part of a complete end-to-end trading system:
- Main Repository: fpga-trading-systems
- Project Number: 29 of 30
- Category: C++ Application
- Dependencies: Projects 24-28 (Trading system components)
SDL2 DRM/KMS graphical control panel for TradingOS, running directly on framebuffer without X11 or Wayland.
A dedicated graphical interface for monitoring and controlling the FPGA trading system. Renders directly to the framebuffer using SDL2's DRM/KMS backend, eliminating display server overhead and providing minimal-latency visual updates on a 5120x1440 ultrawide display.
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ Project 29: TradingOS Control Panel │
├─────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌─────────────────┐ ┌────────────────┐ │
│ │ UIManager │ ←→ │ ProcessManager │ ←→ │ MetricsReader │ │
│ │ │ │ │ │ │ │
│ │ • SDL2 init │ │ • fork/exec │ │ • CPU usage │ │
│ │ • Rendering │ │ • SCHED_FIFO │ │ • GPU usage │ │
│ │ • Events │ │ • CPU affinity │ │ • Memory │ │
│ │ • Fonts │ │ • Health check │ │ • Prometheus │ │
│ └──────────────┘ └─────────────────┘ └────────────────┘ │
│ │ │ │ │
│ └────────────────────┼─────────────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ Widgets │ │
│ │ ┌───────────┐ ┌──────────────┐ ┌─────────────┐ ┌──────────┐ ┌────────┐ │ │
│ │ │ StatusBox │ │ ProgressBar │ │ LogViewer │ │ Button │ │ Header │ │ │
│ │ │ (P24-P26) │ │ (CPU/GPU/Mem)│ │ (sys log) │ │ (actions)│ │ (logo) │ │ │
│ │ └───────────┘ └──────────────┘ └─────────────┘ └──────────┘ └────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ Display: 5120x1440 ultrawide @ 30 FPS (DRM/KMS direct framebuffer) │
└─────────────────────────────────────────────────────────────────────────────────────┘
- Process Control: Start, stop, restart P24 (Order Gateway), P25 (Market Maker), P26 (Execution Engine)
- Real-time Metrics: CPU, GPU, and memory utilization progress bars
- Per-process Status: Running state, BBO/s throughput, latency measurements
- System Log Viewer: Color-coded log levels (INFO, WARN, ERROR)
- Keyboard Navigation: Tab/Shift+Tab focus cycling, Enter to activate
- About Dialog: System information and version display
- Background Logo: Subtle 5120x1440 branded background
- Resolution: 5120x1440 ultrawide fullscreen
- Backend: SDL2 DRM/KMS (no X11/Wayland required)
- Frame Rate: 30 FPS (configurable)
- Color Scheme: Dark theme with cyan accents
| Library | Purpose | Required |
|---|---|---|
| SDL2 | Core graphics and input | Yes |
| SDL2_image | PNG logo loading | Optional |
| SDL2_ttf | TrueType font rendering | Optional |
| nlohmann/json | Configuration parsing | Yes |
Without SDL2_ttf, the application falls back to bitmap text rendering.
cd 29-trading-ui
mkdir -p build && cd build
cmake ..
make -j$(nproc)./build-with-buildroot.shConfiguration file: config.json
{
"display": {
"width": 5120,
"height": 1440,
"fullscreen": true,
"fps_limit": 30
},
"processes": {
"p24": {
"name": "Order Gateway",
"executable": "/opt/trading/bin/order_gateway",
"config": "/opt/trading/config/p24_config.json",
"cpu_core": 14,
"rt_priority": 80
},
"p25": {
"name": "Market Maker",
"executable": "/opt/trading/bin/market_maker",
"config": "/opt/trading/config/p25_config.json",
"cpu_core": 18,
"rt_priority": 70
},
"p26": {
"name": "Execution Engine",
"executable": "/opt/trading/bin/order_execution",
"config": "/opt/trading/config/p26_config.json",
"cpu_core": 19,
"rt_priority": 75
}
},
"assets": {
"logo": "/opt/trading/assets/logo2.png",
"font": "/opt/trading/assets/DejaVuSans.ttf"
}
}Usage: trading_ui [options]
Options:
-c <file> Config file (default: /opt/trading/config/ui_config.json)
-w Windowed mode (for development)
-h Show help
# Force DRM/KMS backend
export SDL_VIDEODRIVER=kmsdrm
./trading_ui./trading_ui -w29-trading-ui/
├── CMakeLists.txt
├── config.json
├── README.md
├── start_ui.sh
├── assets/
│ ├── boot_logo.png
│ ├── DejaVuSans.ttf
│ └── DejaVuSerif.ttf
├── include/
│ ├── ui_manager.h
│ ├── process_manager.h
│ ├── metrics_reader.h
│ └── widgets.h
└── src/
├── main.cpp
├── ui_manager.cpp
├── process_manager.cpp
├── metrics_reader.cpp
└── widgets.cpp
| Widget | Purpose |
|---|---|
Button |
Clickable action button with focus support |
StatusBox |
Process status display with embedded buttons |
ProgressBar |
System metric visualization |
LogViewer |
Scrolling system log display |
Header |
Title bar with logo |
BackgroundLogo |
Full-screen background image |
AboutDialog |
Modal information dialog |
The ProcessManager class handles:
- fork/exec: Spawning trading processes
- SCHED_FIFO: Real-time scheduling with configurable priority
- CPU Affinity: Pinning processes to specific cores
- Health Monitoring: Periodic process status checks
- Signal Handling: Graceful shutdown via SIGTERM
The control panel is designed to run on TradingOS, a custom Linux distribution built with Buildroot. On boot, the system launches directly into this graphical interface without a desktop environment.
Startup sequence:
- TradingOS kernel boots
- systemd starts trading-ui.service
- SDL2 connects to DRM/KMS
- Control panel renders to framebuffer
- User controls trading processes via touch/keyboard
- C++20: Core language
- SDL2: Graphics and input (DRM/KMS backend)
- nlohmann/json: Configuration parsing
- POSIX: Process management (fork, exec, signals)
Complete - Runs on dedicated 5120x1440 ultrawide display without desktop environment.