powerpods/goTool/cmd_led_ring.go
simon 508b684fdf Add UART LED_RING command for progress bar, digits, and clear.
Stop the main-loop digit demo so host-driven display persists; expose
clear/progress/digit modes with RGB and intensity via protobuf and goTool.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 21:18:18 +02:00

57 lines
1.4 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"
)
const (
ledRingModeClear = 0
ledRingModeProgress = 1
ledRingModeDigit = 2
)
func runLedRing(sp *serialPort, args []string) error {
fs := flag.NewFlagSet("led-ring", flag.ExitOnError)
mode := fs.String("mode", "progress", "clear, progress, or digit")
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")
if err := fs.Parse(args); err != nil {
return err
}
var modeVal uint32
switch *mode {
case "clear":
modeVal = ledRingModeClear
case "progress":
modeVal = ledRingModeProgress
case "digit":
modeVal = ledRingModeDigit
default:
return fmt.Errorf("unknown -mode %q (clear, progress, digit)", *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),
})
if err != nil {
return err
}
fmt.Printf("success=%v mode=%d progress=%d digit=%d\n",
resp.GetSuccess(), resp.GetMode(), resp.GetProgress(), resp.GetDigit())
return nil
}