feat: port the remaining v1 API to the v2 controller

Profiles seed presets, a default zone and a palette, and clone with their
own copies; deleting a profile removes what it owned. Zones get the v1
list shape, set-current, current, clone and content-fragment. Devices are
keyed by MAC with v1 validation and identify. Patterns: definitions, OTA
file and manifest, upload, driver, and send over ESP-NOW (the led-driver
pattern sources are embedded in the firmware). Pixel outputs get v1
validation and a DDP/Art-Net/sACN test pattern. Sequences, palettes and
settings follow v1 replies and validation, and /ws forwards browser
messages to the drivers.

The resource handlers move out of api.c into res_*.c, patterns.c and
outputs.c. cJSON now allocates from PSRAM: the store had grown enough to
starve internal RAM and abort the mic at boot. /status reports
free_internal.

The Wi-Fi AP and led-tool routes are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-11-03 09:58:17 +13:00
1 parent 4b42391a46
commit 57182188ba
30 files changed
+2846 -425

No files matched your search

+12 -4
View File
@@ -31,22 +31,30 @@ npx --yes html-minifier-terser@7.2.0 --collapse-whitespace --remove-comments \
find "$OUT" -type f -exec gzip -9 -n -f {} \;
find "$OUT" -name '*.gz' -exec gzip -t {} \;
# led-driver pattern sources, kept uncompressed: the controller serves them and pushes them to drivers
mkdir -p "$OUT/patterns"
cp led-driver/src/patterns/*.py "$OUT/patterns/"
total=$(find "$OUT" -name '*.gz' -printf '%s\n' | paste -sd+ | bc)
echo "www_dist: $(find "$OUT" -name '*.gz' | wc -l) files, $total bytes (limit $MAX)"
(( total <= MAX )) || { echo "ERROR: web UI exceeds the size limit" >&2; exit 1; }
# One blob for the firmware: "WWW1", then per file u16 name length, u32 data length, name (no .gz),
# data; a zero name length ends it. Little-endian, read by main/web.c.
# data; a zero name length ends it. Little-endian, read by main/web.c. patterns/*.py go in as they are.
python3 - "$OUT" <<'PY'
import os, struct, sys
root = sys.argv[1]
out = bytearray(b"WWW1")
for dirpath, _, names in sorted(os.walk(root)):
for n in sorted(names):
if not n.endswith(".gz"):
continue
full = os.path.join(dirpath, n)
name = os.path.relpath(full, root)[:-3].encode()
rel = os.path.relpath(full, root)
if rel.startswith("patterns/") and n.endswith(".py"):
name = rel.encode()
elif n.endswith(".gz"):
name = rel[:-3].encode()
else:
continue
data = open(full, "rb").read()
out += struct.pack("<HI", len(name), len(data)) + name + data
out += struct.pack("<H", 0)