mirror of https://github.com/kidoman/embd
better example for all values
Signed-off-by: Krasi Georgiev <krasi.root@gmail.com>
This commit is contained in:
parent
1f5b11a03e
commit
c3c55b2dc8
|
@ -25,7 +25,8 @@ func main() {
|
||||||
|
|
||||||
bus := embd.NewI2CBus(1)
|
bus := embd.NewI2CBus(1)
|
||||||
|
|
||||||
sensor, _ := mpu6050.New(bus, &mpu6050.Config{GiroScale: "1000", Dlpf: "6"})
|
sensor, _ := mpu6050.New(bus, &mpu6050.Config{GiroScale: "1000", AccelScale: "4g", Dlpf: "6"})
|
||||||
|
// GiroScale, Dlpf, AccelScale can be omited to use the defaults
|
||||||
|
|
||||||
sensor.Start()
|
sensor.Start()
|
||||||
defer sensor.Close()
|
defer sensor.Close()
|
||||||
|
@ -35,13 +36,19 @@ func main() {
|
||||||
signal.Notify(stop, os.Interrupt, os.Kill)
|
signal.Notify(stop, os.Interrupt, os.Kill)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
reading := sensor.Read()
|
||||||
|
o := reading.Orientation()
|
||||||
|
v := reading.Velocity()
|
||||||
|
t := reading.Temperature()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
v := sensor.Read().Orientation()
|
|
||||||
print("\033[H\033[2J") // clear the screen for every read
|
print("\033[H\033[2J") // clear the screen for every read
|
||||||
|
fmt.Println(o)
|
||||||
fmt.Println(v)
|
fmt.Println(v)
|
||||||
|
fmt.Println(t)
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (r *MPU6050Reading) Velocity() velocity {
|
||||||
return r.gReading
|
return r.gReading
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *MPU6050Reading) Temp() temperature {
|
func (r *MPU6050Reading) Temperature() temperature {
|
||||||
return r.tReading
|
return r.tReading
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue