mirror of
https://github.com/kidoman/embd
synced 2024-12-22 04:40:04 +01:00
l3gd20: reset the timer after reading gyro reading
This commit is contained in:
parent
2218fba756
commit
cce1943e34
@ -338,7 +338,11 @@ func (d *L3GD20) Start() (err error) {
|
||||
var orientations chan Orientation
|
||||
oldTime := time.Now()
|
||||
|
||||
timer := time.Tick(time.Duration(d.Poll) * time.Millisecond)
|
||||
var timer <-chan time.Time
|
||||
resetTimer := func() {
|
||||
timer = time.After(time.Duration(d.Poll) * time.Millisecond)
|
||||
}
|
||||
resetTimer()
|
||||
|
||||
for {
|
||||
select {
|
||||
@ -355,6 +359,7 @@ func (d *L3GD20) Start() (err error) {
|
||||
orientations = d.orientations
|
||||
}
|
||||
oldTime = currTime
|
||||
resetTimer()
|
||||
case orientations <- Orientation{x, y, z}:
|
||||
orientations = nil
|
||||
case waitc := <-d.closing:
|
||||
@ -374,6 +379,7 @@ func (d *L3GD20) Stop() (err error) {
|
||||
waitc := make(chan struct{})
|
||||
d.closing <- waitc
|
||||
<-waitc
|
||||
d.closing = nil
|
||||
}
|
||||
if err = d.Bus.WriteByteToReg(address, ctrlReg1, ctrlReg1Finished); err != nil {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user