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 }