Dim LED ring, add blink mode, and signal OTA outcome on the ring.

Default brightness is ~5%; UART blink mode and green/red pulses mark OTA success or failure. Failed UART uploads skip ESP-NOW distribution.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-19 21:53:10 +02:00
co-authored by Cursor
parent 508b684fdf
commit 8931912583
13 changed files with 324 additions and 71 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ go run . -port /dev/ttyUSB0 clients
| `serve` | — | Web dashboard at `http://localhost:8080` (WebSocket live updates) |
| `ota` | 1619 | UART firmware upload to master; firmware then pushes to slaves via ESP-NOW |
| `ota-progress` | 21 | Query per-slave ESP-NOW OTA progress on the master (`-client N`, default all) |
| `led-ring` | 8 | LED ring: `-mode clear\|progress\|digit`, `-progress`, `-digit`, RGB, `-intensity` |
| `led-ring` | 8 | LED ring: `-mode clear\|progress\|digit\|blink`, `-progress`, `-digit`, RGB, `-intensity` (0 = ~5 %), `-blink-ms`, `-blink-count` |
`clients` requires slaves to have responded to master discover broadcasts first.
+17 -10
View File
@@ -11,17 +11,20 @@ const (
ledRingModeClear = 0
ledRingModeProgress = 1
ledRingModeDigit = 2
ledRingModeBlink = 3
)
func runLedRing(sp *serialPort, args []string) error {
fs := flag.NewFlagSet("led-ring", flag.ExitOnError)
mode := fs.String("mode", "progress", "clear, progress, or digit")
mode := fs.String("mode", "progress", "clear, progress, digit, or blink")
progress := fs.Uint("progress", 0, "fill level 0100 (mode=progress)")
digit := fs.Uint("digit", 0, "digit 010 (mode=digit)")
r := fs.Uint("r", 0, "red 0255")
g := fs.Uint("g", 255, "green 0255")
b := fs.Uint("b", 0, "blue 0255")
intensity := fs.Uint("intensity", 255, "brightness 0255")
intensity := fs.Uint("intensity", 0, "brightness 0255 (0 = device default ~5%)")
blinkMs := fs.Uint("blink-ms", 350, "pulse length in ms (mode=blink)")
blinkCount := fs.Uint("blink-count", 1, "number of pulses (mode=blink)")
if err := fs.Parse(args); err != nil {
return err
}
@@ -34,18 +37,22 @@ func runLedRing(sp *serialPort, args []string) error {
modeVal = ledRingModeProgress
case "digit":
modeVal = ledRingModeDigit
case "blink":
modeVal = ledRingModeBlink
default:
return fmt.Errorf("unknown -mode %q (clear, progress, digit)", *mode)
return fmt.Errorf("unknown -mode %q (clear, progress, digit, blink)", *mode)
}
resp, err := sp.ledRingProgress(&pb.LedRingProgressRequest{
Mode: modeVal,
Progress: uint32(*progress),
Digit: uint32(*digit),
R: uint32(*r),
G: uint32(*g),
B: uint32(*b),
Intensity: uint32(*intensity),
Mode: modeVal,
Progress: uint32(*progress),
Digit: uint32(*digit),
R: uint32(*r),
G: uint32(*g),
B: uint32(*b),
Intensity: uint32(*intensity),
BlinkMs: uint32(*blinkMs),
BlinkCount: uint32(*blinkCount),
})
if err != nil {
return err
+27 -6
View File
@@ -1068,8 +1068,8 @@ func (x *EspNowUnicastTestResponse) GetSeq() uint32 {
return 0
}
// Host → device: LED ring display (progress bar, digit, or clear).
// mode: 0=clear, 1=progress (0100 %), 2=digit (010, same layout as firmware digit maps).
// Host → device: LED ring display (progress bar, digit, clear, or blink).
// mode: 0=clear, 1=progress (0100 %), 2=digit (010), 3=blink full ring.
type LedRingProgressRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Mode uint32 `protobuf:"varint,1,opt,name=mode,proto3" json:"mode,omitempty"`
@@ -1080,8 +1080,12 @@ type LedRingProgressRequest struct {
R uint32 `protobuf:"varint,4,opt,name=r,proto3" json:"r,omitempty"`
G uint32 `protobuf:"varint,5,opt,name=g,proto3" json:"g,omitempty"`
B uint32 `protobuf:"varint,6,opt,name=b,proto3" json:"b,omitempty"`
// * 0255 brightness scale applied to r/g/b
Intensity uint32 `protobuf:"varint,7,opt,name=intensity,proto3" json:"intensity,omitempty"`
// * 0255 brightness scale; 0 = firmware default (~5 %)
Intensity uint32 `protobuf:"varint,7,opt,name=intensity,proto3" json:"intensity,omitempty"`
// * Pulse length in ms (mode=blink, default 350)
BlinkMs uint32 `protobuf:"varint,8,opt,name=blink_ms,json=blinkMs,proto3" json:"blink_ms,omitempty"`
// * Number of pulses (mode=blink, default 1)
BlinkCount uint32 `protobuf:"varint,9,opt,name=blink_count,json=blinkCount,proto3" json:"blink_count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1165,6 +1169,20 @@ func (x *LedRingProgressRequest) GetIntensity() uint32 {
return 0
}
func (x *LedRingProgressRequest) GetBlinkMs() uint32 {
if x != nil {
return x.BlinkMs
}
return 0
}
func (x *LedRingProgressRequest) GetBlinkCount() uint32 {
if x != nil {
return x.BlinkCount
}
return 0
}
type LedRingProgressResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
@@ -1707,7 +1725,7 @@ const file_uart_messages_proto_rawDesc = "" +
"\x03seq\x18\x02 \x01(\rR\x03seq\"G\n" +
"\x19EspNowUnicastTestResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x10\n" +
"\x03seq\x18\x02 \x01(\rR\x03seq\"\xa6\x01\n" +
"\x03seq\x18\x02 \x01(\rR\x03seq\"\xe2\x01\n" +
"\x16LedRingProgressRequest\x12\x12\n" +
"\x04mode\x18\x01 \x01(\rR\x04mode\x12\x1a\n" +
"\bprogress\x18\x02 \x01(\rR\bprogress\x12\x14\n" +
@@ -1715,7 +1733,10 @@ const file_uart_messages_proto_rawDesc = "" +
"\x01r\x18\x04 \x01(\rR\x01r\x12\f\n" +
"\x01g\x18\x05 \x01(\rR\x01g\x12\f\n" +
"\x01b\x18\x06 \x01(\rR\x01b\x12\x1c\n" +
"\tintensity\x18\a \x01(\rR\tintensity\"y\n" +
"\tintensity\x18\a \x01(\rR\tintensity\x12\x19\n" +
"\bblink_ms\x18\b \x01(\rR\ablinkMs\x12\x1f\n" +
"\vblink_count\x18\t \x01(\rR\n" +
"blinkCount\"y\n" +
"\x17LedRingProgressResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x12\n" +
"\x04mode\x18\x02 \x01(\rR\x04mode\x12\x1a\n" +