Files
powerpods/goTool/cmd_led_ring.go
T
skrueckenandCursor f006f8b912 Add software LiPo UV protection with energy-save boot.
Detect under-voltage on GPIO1/11, persist UV state in NVS, enter a minimal
power mode without ESP-NOW, and recover after charge; expose LED mode 6
battery-low for host testing via goTool.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 18:22:52 +02:00

55 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"flag"
"fmt"
"powerpod/gotool/pb"
)
func runLedRing(sp *serialPort, args []string) error {
fs := flag.NewFlagSet("led-ring", flag.ExitOnError)
mode := fs.String("mode", "progress", "clear, color, progress, digit, blink, find-me, or battery-low")
clientID := fs.Uint("client", 0, "0=master ring, >0=slave via ESP-NOW")
allClients := fs.Bool("all", false, "broadcast to all slaves")
slavesOnly := fs.Bool("slaves-only", false, "with -all: do not change master ring")
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", 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
}
modeVal, err := ledRingModeFromString(*mode)
if err != nil {
return err
}
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),
BlinkMs: uint32(*blinkMs),
BlinkCount: uint32(*blinkCount),
ClientId: uint32(*clientID),
AllClients: *allClients,
SlavesOnly: *slavesOnly,
})
if err != nil {
return err
}
fmt.Printf("success=%v mode=%d progress=%d digit=%d client_id=%d slaves_updated=%d\n",
resp.GetSuccess(), resp.GetMode(), resp.GetProgress(), resp.GetDigit(),
resp.GetClientId(), resp.GetSlavesUpdated())
return nil
}