README, API, help, P4_NANO and the sub-READMEs now describe the ESP32-P4-Nano controller and the simulator on it. API.md gains the users and permissions routes; BENCH_TEST and SPECIFICATION are marked historical. Screenshots of the simulator, sequence editor and pattern gallery. Graph rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
3.9 KiB
Markdown
74 lines
3.9 KiB
Markdown
# led-controller on a desktop
|
|
|
|
The controller firmware (`main/`) built as a program for Linux: no ESP-IDF, no Docker, no board. The web
|
|
UI and API are the same as the board's. ESP-NOW goes through bridges: a USB bridge board (`bridge/`), a network
|
|
bridge (a bridge board with Ethernet, or the ESP32-P4-Nano controller at `192.168.50.20:8766`, see `docs/P4_NANO.md`),
|
|
DMX bridges, and the simulated rig at `/sim/` (`make sim-wasm` first; see `led-simulator/README.md`).
|
|
|
|
## Build and run
|
|
|
|
Needs `cmake`, a C compiler, and `www_dist/www.pack` (`make web` builds it with `node`).
|
|
|
|
```bash
|
|
make desktop # builds build-desktop/led-controller
|
|
make desktop-run # the web UI on http://localhost:8080/
|
|
make test-desktop # starts the program and runs the API tests against it
|
|
```
|
|
|
|
Or run it directly:
|
|
|
|
```bash
|
|
build-desktop/led-controller --db ./data --port 8080
|
|
```
|
|
|
|
| option | environment | meaning |
|
|
| --- | --- | --- |
|
|
| `--db DIR` | `LED_CONTROLLER_DB` | the store (default `/db`) |
|
|
| `--port N` | `LED_CONTROLLER_HTTP_PORT` | web UI and API port (default 8080) |
|
|
|
|
`LED_LOG_LEVEL=error|warn|info|debug|verbose` sets how much is logged (default `info`).
|
|
|
|
## Install as a service (.deb)
|
|
|
|
```bash
|
|
make deb # build-desktop/led-controller_0.1.0_<arch>.deb
|
|
sudo apt install ./build-desktop/led-controller_0.1.0_*.deb
|
|
```
|
|
|
|
The package installs `/usr/bin/led-controller`, the `led-cli` command-line tool (`/usr/bin/led-cli`), the LED driver
|
|
firmware image (`/usr/share/led-controller/firmware/led_driver.bin`), a systemd unit (`led-controller.service`) that runs it as a
|
|
dynamic user with its store in `/var/lib/led-controller`, and `/etc/default/led-controller` for the port. The service starts at install and restarts after a restart from
|
|
the web UI. The bridges are kept in the controller's settings, so set them in the web UI under Settings > Network >
|
|
Bridges. Change the port in `/etc/default/led-controller`, then `sudo systemctl restart led-controller`. The bridge's serial port is
|
|
owned by `dialout`, which the service joins.
|
|
|
|
`packaging/led-bridge.udev.example` (installed in `/usr/share/doc/led-controller/`) gives the bridge board a
|
|
stable name, `/dev/led-bridge`, by its serial number.
|
|
|
|
## How it is built
|
|
|
|
`desktop/CMakeLists.txt` compiles the firmware's own sources (`main/`, and the host stand-ins and the
|
|
simulated rig in `sim-controller/components/sim/`: OTA, littlefs, the timers, `sim_rig.c` and `sim_net.c`) with a small port of the ESP-IDF APIs
|
|
they use:
|
|
|
|
- `port/src/freertos.c`: tasks, queues, semaphores, stream buffers and event groups on POSIX threads.
|
|
- `port/src/esp_glue.c`: logging, error names, random numbers, the MAC (from the first real network
|
|
interface), restart (an exit, for the service manager), and the app description.
|
|
- `port/src/desktop_crypto.c`: SHA-1 and base64 for the WebSocket handshake.
|
|
- `port/src/www_pack.c`, `sim_pack.c`: the web UI and simulator packs (`www_dist/www.pack`, `sim.pack`) embedded in the
|
|
program.
|
|
- `port/src/mic_alsa.c`, `mdns_host.c`: the microphone and the mDNS browser.
|
|
- `port/include/`: the headers. `sdkconfig.h` is the config the sim's build generated.
|
|
|
|
Third-party code is vendored in `third_party/`: the HTTP server and `http_parser` from ESP-IDF v6.1, and cJSON.
|
|
`tools/vendor.sh` refreshes them (it runs `espressif/idf:v6.1` to copy the httpd sources). Its patch
|
|
(`tools/patch_vendor.py`) swaps the handshake's mbedTLS and PSA calls for `desktop_crypto.c`.
|
|
|
|
## Limits
|
|
|
|
- ESP-NOW needs a bridge. With none in the settings the program runs the `browser` bridge, so its frames only reach the
|
|
simulated rig.
|
|
- Firmware OTA is not available (the API answers 501, as in the simulator).
|
|
- The microphone is the computer's (ALSA) or a bridge board's. While audio is stopped, beats come from the BPM clock.
|
|
- Wi-Fi drivers are found over mDNS (`port/src/mdns_host.c`).
|