docs: P4-Nano controller and simulator, users API, README screenshots

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>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-24 22:09:28 +13:00
1 parent 8756315a7b
commit e0c6c36996
32 files changed
+269751 -683

No files matched your search

+28 -6
View File
@@ -1,6 +1,6 @@
# LED Controller API
The controller is an ESP32-S3 on Ethernet (W5500). It serves the web UI and a JSON API on port 80, detects beats from its I2S microphone and talks to the LED drivers over ESP-NOW. This document covers:
The controller is a Waveshare ESP32-P4-Nano on Ethernet ([P4_NANO.md](P4_NANO.md)). It serves the web UI and a JSON API on port 80, detects beats from its microphone and talks to the LED drivers over ESP-NOW through the board's ESP32-C6. The host builds (desktop, Docker, sim) serve the same API, on port 8080 by default; differences are marked. This document covers:
1. The HTTP and WebSocket API, by resource.
2. How the controller turns API calls into driver messages, and the message format.
@@ -26,6 +26,7 @@ Request and response bodies are JSON (`Content-Type: application/json`) unless n
| GET | `/audio` | Live audio and beat page (level, tempo, bar position, tap) |
| GET | `/settings/editor` | Driver settings editor: sends a driver settings (`PUT /devices/<id>`) |
| GET | `/static/<path>` | UI scripts and styles |
| GET | `/sim/`, `/sim/gallery` | The simulated rig and the pattern gallery. Their API (`/sim/api/*`, `/sim/ws`) is in [`led-simulator/README.md`](../led-simulator/README.md) |
| GET | `/favicon.ico` | 204 |
Pages and static files are built into the firmware (gzipped, sent with `Content-Encoding: gzip`). They carry `Cache-Control: no-cache` and an `ETag` of the firmware build, so a browser revalidates each load (304 until the next update).
@@ -34,13 +35,34 @@ Pages and static files are built into the firmware (gzipped, sent with `Content-
| Method | Path | Description |
|--------|------|-------------|
| GET | `/status` | IP, `eth` (ip, mask, gw, up), `ap_ip`, `ap_clients` (`[{mac, ip}]` on the Wi-Fi access point), MAC, uptime, `free_heap`, `free_internal` (internal RAM), mic level, tempo and beat counts, ESP-NOW and link statistics |
| GET | `/status` | IP, `eth` (ip, mask, gw, up), `ap_ip`, `ap_clients` (`[{mac, ip}]` on the Wi-Fi access point), MAC, uptime, `free_heap`, `free_internal` (internal RAM), mic level, tempo and beat counts, ESP-NOW and link statistics. Host builds add `sim`, `bridge`, `bridges` and `bridge_links`; on the board the bridges are in `GET /settings/bridge` |
| POST | `/reboot` | Replies `{"message":"rebooting"}`, then restarts after 0.5 s |
| GET | `/ota` | Running image: partition, version, build time, IDF version, sha |
| POST | `/ota` | Body: the raw firmware `.bin` (web UI included). Written to the idle slot, made the boot image, then the board reboots. A new image confirms itself after staying up a few seconds; one that crashes on start rolls back. `make ota HOST=<ip>` |
| GET | `/db/<collection>` | Export a whole collection |
| PUT | `/db/<collection>` | Replace a whole collection. Body: the object of id → record. Reply: `{"records": n}` |
## Users and permissions — `/auth`
Off until the first user exists: until then every request is allowed. From then on a request needs a session and a role with enough permission for its area. Signed-out requests have the `guest` role. The last user who can manage users cannot be removed, so the API cannot switch this off again.
- **Levels:** 0 none, 1 view, 2 control (play, stop, brightness, identify and the like), 3 edit.
- **Areas:** `presets`, `sequences`, `zones` (with profiles and scenes), `groups`, `devices`, `outputs`, `patterns` (with palettes), `sim`, `settings` (with bridges, audio, OTA, reboot and bench tests), `users`. `/db` needs edit on `settings`, reads included.
- **Always public:** the main page, static files, `/status`, the audio page and the simulator's files.
- **Built-in roles:** `admin` (edit everywhere, fixed) and `guest` (editable).
- **Session:** a `led_session` cookie, 30 days. Sessions are kept in memory, so a restart signs everyone out.
| Method | Path | Description |
|--------|------|-------------|
| GET | `/auth` | `{enabled, user, role, perms: {area: level}}` for this request |
| POST | `/auth/login` | `{username, password}`. 401 when wrong, 429 after too many attempts |
| POST | `/auth/logout` | Ends the session |
| PUT | `/auth/password` | `{old, new}`: the signed-in user's own password, 8–128 characters |
| GET, POST | `/auth/users` | List; create `{username, password, role}` |
| PUT, DELETE | `/auth/users/<name>` | Change `role` and/or `password`; delete |
| GET, POST | `/auth/roles` | List; create `{name, perms: {area: level}}` |
| PUT, DELETE | `/auth/roles/<name>` | Change `perms`; delete (not a built-in role, nor one in use) |
**Bench tests** (see `docs/BENCH_TEST.md`):
| Method | Path | Description |
@@ -61,11 +83,11 @@ Keys with meaning on the controller (others are stored as they are):
| Key | Checked | Meaning |
|-----|---------|---------|
| `ap_enabled` | | Wi-Fi access point (open, SSID = hostname, `192.168.5.1`); default `true`; applies after a restart. Holding the D3 button at boot forces it on |
| `ap_enabled` | | Wi-Fi access point (open, SSID = hostname, `192.168.5.1`); default `true`; applies after a restart. Holding a button wired to the menuconfig "AP button" GPIO at boot forces it on (none by default: the P4-Nano has no user button) |
| `ap_password` | | AP password, 8-63 characters (WPA2); empty (default) is an open network; applies after a restart |
| `bridges` | list of strings | Bridges the ESP-NOW frames go to instead of the radio, each up to 79 characters: `/dev/ttyACM1` (a USB bridge board, or `serial:/dev/...`) `host:port` (UDP: led-simulator, or a network bridge board, default port 8766), or `dmx:<id>` (a DMX bridge, see below; host builds only, and only an id that exists). Every frame goes to each; a frame several bridges hear arrives once. Empty or missing: the radio. The host applies changes at once (`GET`/`PUT /settings/bridge`); a device applies them after a restart. `bridge` (one address) is still read when `bridges` is missing. |
| `bridges` | list of strings | Bridges the ESP-NOW frames go to, each up to 79 characters: `/dev/ttyACM1` (a USB bridge board, or `serial:/dev/...`; host builds only), `host:port` (UDP: led-simulator, or a network bridge board, default port 8766), or `dmx:<id>` (a DMX bridge, see below; host builds only, and only an id that exists), or `browser` (the rig page at `/sim/`). Every frame goes to each; a frame several bridges hear arrives once. The board always runs `c6` (its own radio) and `browser` as well, whatever the list says. A host build with an empty list runs `browser`. The host applies changes at once (`PUT /settings/bridge`); the board applies them after a restart and answers that PUT with 404. `bridge` (one address) is still read when `bridges` is missing. |
| `hostname` | | mDNS name (`<hostname>.local`, default `led-controller`); applies after a restart |
| `static_ips` | | List of `{ip, netmask?, gw, dns?}` tried in order when the Ethernet link comes up; the first whose gateway answers ARP is used, else DHCP, else `192.168.4.1/24` for a direct PC cable. Applies after a restart |
| `static_ips` | | List of `{ip, netmask?, gw, dns?}` tried in order when the Ethernet link comes up; the first whose gateway answers ARP is used, else DHCP, else (no answer in 5 s) `192.168.50.20/24` for a direct PC cable. Applies after a restart |
| `global_brightness` | integer 0–255 | Global factor of each driver's brightness (see Groups). Stored only: the UI pushes each driver its combined value |
| `wifi_channel` | integer 1–11 | Stored for reference. The controller's ESP-NOW channel is set at build time (`make menuconfig`) |
| `audio_simulated_bpm` | clamped to 60–200 | Tempo of the beat clock (default 120) |
@@ -305,7 +327,7 @@ Network pixel fixtures. An output is `{id, name, protocol: "ddp" | "artnet" | "s
Zones do not render to outputs: only the test pattern is sent.
The simulated rig (`/sim/`, host builds) receives Art-Net and DDP, so an output aimed at `127.0.0.1` shows on its DDP and Art-Net fixtures; see `led-simulator/README.md` (Network fixtures) and `GET /sim/api/dmx`.
The simulated rig (`/sim/`) receives Art-Net and DDP, so an output aimed at `127.0.0.1` shows on its DDP and Art-Net fixtures; see `led-simulator/README.md` (Network fixtures) and `GET /sim/api/dmx`.
## DMX bridges — `/dmx-bridges`, `/dmx-definitions`
+5
View File
@@ -1,5 +1,10 @@
# Bench test: one S3 controller and one LED driver
> **Historical.** These runs used the earlier ESP32-S3 controller (W5500, INMP441) and the MicroPython led-driver. The
> controller now builds for the ESP32-P4-Nano only ([P4_NANO.md](P4_NANO.md)): use `make build` and `make flash` in place
> of sections 0 and 1, and its address (`192.168.50.20` on a direct cable) for `$S3`. The `/test/loss` and `/test/beats`
> endpoints below still exist. The results have not been repeated on the P4, where every frame also crosses the C6.
This walks one ESP32-S3 controller (W5500 Ethernet, INMP441 mic) and one `led-driver` unit through flashing, a smoke test, a lossy-link test and a beat latency measurement. Nothing here has been run on hardware yet, so treat the expected numbers as targets to check, not results.
## 0. What you need
+25 -6
View File
@@ -20,8 +20,10 @@ PC <-------------------------------> ESP32-P4 <------------------------------
to the P4. It does the same job as the USB bridge in `bridge/`, but over SDIO.
- **Microphone:** the on-board mic goes through the ES8311 codec, set up over I2C with `esp_codec_dev`. The
rest of the mic path (levels, beat detection, streaming) runs on the P4.
- **Status:** `GET /status` lists the `c6` bridge (kind `c6`). It shows whether the C6 is linked, its MAC and
channel, its counters, and which desktop is using the radio, if any.
- **Status:** `GET /settings/bridge` lists the `c6` bridge (kind `c6`) and the `browser` one ([Simulator](#simulator)).
For `c6` it shows whether the C6 is linked, its MAC and channel, its counters, and which desktop is using the
radio, if any.
- **Cores:** both P4 cores are used. The controller's tasks are not pinned to one.
## Build and flash
@@ -29,7 +31,8 @@ Use ESP-IDF v6.1 (`espressif/idf:v6.1`). The settings are `sdkconfig.defaults` a
`partitions.csv`.
```bash
make build # the web UI, radio-c6/ (C6) and the controller (P4)
make sim-wasm # once, and after led-driver changes: the simulator's drivers
make build # the web UI, the simulator, radio-c6/ (C6) and the controller (P4)
make flash PORT=/dev/ttyACM0 # the controller, plus the C6 image into the slave_fw partition
make log PORT=/dev/ttyACM0 # the console for 10 s (the board's USB-C port is a CH343 UART)
make ota HOST=192.168.50.20 # later updates over Ethernet (not the C6 image: flash for that)
@@ -41,12 +44,23 @@ over esp-hosted OTA and restarts the board. This takes about 10 seconds, and onl
after a change. Never put the one-off updater in `scripts/c6-ota/host-v2` on the board again: it updates the
C6 on every boot.
## Flash layout
`partitions.csv`, 16 MB:
| Partition | Size | What |
| --- | --- | --- |
| `ota_0`, `ota_1` | 3 MB each | the controller, web UI and simulator included |
| `db` | 8.1 MB (0x820000) | LittleFS: the records, and the simulator's rooms and bars in `/db/sim` |
| `slave_fw` | 1.75 MB | the C6 image |
| `nvs`, `otadata`, `phy_init` | 36 KB | |
## Network
The board sits on a cable straight to the PC (192.168.50.10), so there is no DHCP server. At boot it tries:
1. the settings `static_ips`
2. DHCP, for 5 seconds
3. **192.168.50.20/24**, with no gateway (menuconfig "ESP32-P4-Nano")
3. **192.168.50.20/24**, with no gateway (menuconfig "ESP32-P4-Nano board")
The web UI is at http://192.168.50.20/.
@@ -89,10 +103,15 @@ The C6 keeps running `radio-c6`. Waveshare's demo uses an older esp-hosted, whic
## Simulator
The board serves the same simulated rig as the desktop at `/sim/` (Menu > Simulator). The bars run in the browser and
The board serves the same simulated rig as the desktop at `/sim/` (Menu > Simulator; see `led-simulator/README.md`). The
bars run in the browser and
get the controller's frames from the `browser` bridge, which is always on next to `c6`. Frames addressed to simulated
bars (MACs starting 02:51:4d) are not sent over the C6. A page that reads too slowly loses frames; the radio does not
wait for it. Rooms and the bars' flash are in `/db/sim`.
`make build` packs the page from `led-simulator/web`. The bars' WebAssembly comes from `make sim-wasm`; without it
`/sim/` only says how to build it.
`/sim/` only says how to build it. `make build` reuses whatever WebAssembly is there, so run `make sim-wasm` again after
led-driver changes.
Art-Net and DDP sent to the board reach the rig's network fixtures. The board's own outputs reach them too, aimed at
`127.0.0.1`. DMX bridges (`dmx:<id>`) are in the host builds only.
+3
View File
@@ -1,5 +1,8 @@
# LED Driver System - Specification Document
> **Historical.** This describes the first, MicroPython system and the Raspberry Pi controller. The current controller is
> ESP-IDF C on the ESP32-P4-Nano: see [P4_NANO.md](P4_NANO.md) and [API.md](API.md).
**Version:** 1.1
**Date:** October 2026
**Status:** Draft
+16 -3
View File
@@ -1,6 +1,6 @@
# LED controller — user guide
This page describes the web UI served by the controller (an ESP32-S3 on Ethernet). It covers profiles, zones, presets, device groups, sequences and audio. The controller reaches the LED drivers over ESP-NOW itself, so there is no bridge to set up.
This page describes the web UI served by the controller (a Waveshare ESP32-P4-Nano on Ethernet). It covers profiles, zones, presets, device groups, sequences and audio. The controller reaches the LED drivers over ESP-NOW itself, so there is no bridge to set up.
For HTTP routes and the driver message format, see **[API.md](API.md)**. For building and flashing, see the project **README**.
@@ -81,12 +81,21 @@ The preset editor:
- **Steps.** A step is a preset and a number of beats. When a step's beats have passed, the lane moves to its next step. A sequence loops unless you turn looping off.
- **Playing.** Attach a sequence to a zone in the zone editor, then play it from the zone. One sequence plays at a time. Stopping a sequence clears its presets from the zone's drivers.
- **Copy, cut and paste clips.** Select a clip and press **Ctrl+C** to copy it or **Ctrl+X** to cut it (or use **Copy** / **Cut** under the timeline). **Ctrl+V** (or **Paste**) puts it after the selected clip, at the spot you last clicked on a track, or at the first free place on the selected track. The pasted clip is selected, so pressing **Ctrl+V** again lines up more copies. Copies can be pasted into another sequence while the page is open.
- **Simulator or both.** On the desktop app (with the simulator), the editor's **Sim only / Both** switch sets where **Play** plays: **Sim only** plays the sequence on the simulated bars only, in time with the live show, while the real fixtures keep their show; **Stop** then ends just the preview and the bars go back to the live show. **Both** plays it in the current zone, everywhere, as from the zone.
- **Simulator or both.** The editor's **Sim only / Both** switch sets where **Play** plays: **Sim only** plays the sequence on the simulated bars only, in time with the live show, while the real fixtures keep their show; **Stop** then ends just the preview and the bars go back to the live show. **Both** plays it in the current zone, everywhere, as from the zone.
- **Switching.** Starting another sequence waits for the next beat, or the next downbeat when the header toggle says **Downbeat** and the microphone is timing.
- **Syncing.** Press **S** (or the BPM button) on a downbeat to line the sequence up with the music.
---
## Simulator
**Menu → Simulator** opens the simulated rig beside the controls: a room with every LED bar, each running the real driver in your browser. On a phone, swipe between the controls and the rig.
- The bars register like real drivers, so they appear under **Devices** and can be put in groups. They run only while the page is open.
- **Edit room** adds, moves and turns bars, and adds DDP and Art-Net fixtures. **Presets** shows the preset editor in the same pane, and **Pop out** opens the rig in its own window.
- One page at a time runs the rig: opening it somewhere else powers the first one's bars off.
---
## Audio
- The controller listens through its microphone and detects the tempo and the bar.
@@ -108,7 +117,11 @@ The preset editor:
## Settings
**Settings** (Edit mode) holds the controller's name, the ESP-NOW channel (for reference: the controller's channel is set at build time), a **Wi-Fi access point** switch (on by default; network named after the hostname, with an optional WPA2 password, controller at `192.168.5.1`; holding the button on D3 at boot forces it on), its mDNS **hostname** and the **static IPs** it tries on the Ethernet link (DHCP when none answers). With no DHCP server, as on a cable straight to a PC, the controller is at `192.168.4.1`; give the PC a static IP such as `192.168.4.2`. Network changes apply after a restart. **Driver** in Settings sends a driver its name, LED count, colour order, startup mode, maximum brightness and direction over ESP-NOW, with no cable. **Update code** there sends a driver, or all of them, the led-driver code built into the controller. `led-cli` on a computer edits a driver's whole `settings.json` over USB.
**Settings** (Edit mode) holds the controller's name, the ESP-NOW channel (for reference: the controller's channel is set at build time), a **Wi-Fi access point** switch (on by default; network named after the hostname, with an optional WPA2 password, controller at `192.168.5.1`), its mDNS **hostname** and the **static IPs** it tries on the Ethernet link (DHCP when none answers). With no DHCP server, as on a cable straight to a PC, the controller is at `192.168.50.20`; give the PC a static IP such as `192.168.50.10`. Network changes apply after a restart. **Driver** in Settings sends a driver its name, LED count, colour order, startup mode, maximum brightness and direction over ESP-NOW, with no cable. **Update code** there sends a driver, or all of them, the led-driver code built into the controller. `led-cli` on a computer edits a driver's whole `settings.json` over USB.
### Users
**Settings → Users** adds users and roles. Until the first user exists anyone on the network can do everything. After that, people sign in, and a role says what they may do in each area: nothing, view, control or edit. Visitors who are not signed in have the **guest** role. At least one user who can manage users must stay, so this cannot be switched off again from the page.
### DMX bridges (desktop and Docker controllers)
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB