Add LED ring control per client and broadcast over REST and WebSocket.

Solid color mode fills all ring LEDs; master routes UART commands to slaves
via ESPNOW_LED_RING. goTool exposes POST /api/led-ring, WebSocket set_led_ring,
and a dashboard LED panel with master/slave/all targets.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-29 19:24:55 +02:00
co-authored by Cursor
parent 47c75110c9
commit eb67a46158
21 changed files with 759 additions and 133 deletions
+36
View File
@@ -0,0 +1,36 @@
package main
import (
"encoding/json"
"net/http"
)
func mountLedRingAPI(mux *http.ServeMux, link *managedSerial) {
mux.HandleFunc("/api/led-ring", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
serveLedRingPost(w, r, link)
})
}
func serveLedRingPost(w http.ResponseWriter, r *http.Request, link *managedSerial) {
var body ledRingAPIRequest
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
writeJSON(w, http.StatusBadRequest, ledRingAPIResponse{Error: "invalid JSON"})
return
}
if body.Mode == "" {
writeJSON(w, http.StatusBadRequest, ledRingAPIResponse{Error: "mode required"})
return
}
out := applyLedRing(link, body)
status := http.StatusOK
if out.Error != "" {
status = http.StatusServiceUnavailable
} else if !out.Success {
status = http.StatusServiceUnavailable
}
writeJSON(w, status, out)
}