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>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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 0–100 (mode=progress)")
|
||||
digit := fs.Uint("digit", 0, "digit 0–10 (mode=digit)")
|
||||
r := fs.Uint("r", 0, "red 0–255")
|
||||
g := fs.Uint("g", 255, "green 0–255")
|
||||
b := fs.Uint("b", 0, "blue 0–255")
|
||||
intensity := fs.Uint("intensity", 255, "brightness 0–255")
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user