mpu/main.go

44 lines
769 B
Go
Raw Permalink Normal View History

2024-07-24 11:29:00 +00:00
package main
import (
"log"
2024-07-25 12:30:09 +00:00
"time"
2024-07-24 11:29:00 +00:00
2024-08-09 09:02:52 +00:00
"gitea.unprism.ru/KRBL/mpu/pkg/mpu6050"
2024-07-24 11:29:00 +00:00
)
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
}
2024-07-24 12:40:35 +00:00
log.Println("LOOP")
log.Println("ACCEL")
for {
2024-07-25 12:30:09 +00:00
// temp, err := mpu.GetTemp()
// if err != nil {
// return err
2024-07-25 12:30:09 +00:00
// }
2024-07-24 12:40:35 +00:00
accel, err := mpu.GetAccel(false)
if err != nil {
return err
}
gyro, err := mpu.GetGyro()
if err != nil {
return err
}
2024-07-25 12:30:09 +00:00
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)
2024-07-24 11:29:00 +00:00
}
}