44 lines
690 B
Go
44 lines
690 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/CGSG-2021-AE4/mpu-test/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
|
|
}
|
|
log.Println("Temp:", temp)
|
|
|
|
accel, err := mpu.GetAccel(false)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Println("Accel:", accel)
|
|
gyro, err := mpu.GetGyro()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Println("Gyro:", gyro)
|
|
}
|
|
}
|