mpu/main.go
2024-08-09 12:02:52 +03:00

44 lines
769 B
Go

package main
import (
"log"
"time"
"gitea.unprism.ru/KRBL/mpu/pkg/mpu6050"
)
func main() {
log.Println("CGSG forever!!!")
if err := mainE(); err != nil {
log.Println("MAIN finished with error:", err.Error())
}
log.Println("END")
}
func mainE() error {
log.Println("OPEN")
mpu, err := mpu6050.Open()
if err != nil {
return err
}
log.Println("LOOP")
log.Println("ACCEL")
for {
// temp, err := mpu.GetTemp()
// if err != nil {
// return err
// }
accel, err := mpu.GetAccel(false)
if err != nil {
return err
}
gyro, err := mpu.GetGyro()
if err != nil {
return err
}
log.Printf("%9.6f\t%9.6f\t%9.6f\t%9.6f\t%9.6f\t%9.6f\n", accel[0], accel[1], accel[2], gyro[0], gyro[1], gyro[2])
time.Sleep(100 * time.Millisecond)
}
}