powerpods/goTool/cmd_accel.go
simon 47c75110c9 Stream slave accel via ESP-NOW with master snapshot cache.
Slaves push BMA456 samples at 16ms when enabled; the master caches per
client and exposes ACCEL_SNAPSHOT and ACCEL_STREAM over UART. goTool adds
dashboard stream controls, HTTP accel-stream routes, and an external
WebSocket API with per-connection receive/interval and slave stream commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 19:11:36 +02:00

31 lines
660 B
Go

package main
import (
"fmt"
)
func runAccel(sp *serialPort) error {
return runAccelSnapshot(sp, 0)
}
func runAccelSnapshot(sp *serialPort, clientID uint32) error {
r, err := sp.readAccelSnapshot(clientID)
if err != nil {
return err
}
samples := r.GetSamples()
if len(samples) == 0 {
fmt.Println("no accel samples (no slaves or no ESP-NOW stream yet)")
return nil
}
for _, s := range samples {
if !s.GetValid() {
fmt.Printf("client %d: no sample yet\n", s.GetClientId())
continue
}
fmt.Printf("client %d: x=%d y=%d z=%d (age %d ms, raw LSB ±2g)\n",
s.GetClientId(), s.GetX(), s.GetY(), s.GetZ(), s.GetAgeMs())
}
return nil
}