Now using the original time that the event was received instead of when
it is processed by bluetooth.
This commit is contained in:
parent
87ba3cdba7
commit
7644ab2e4d
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/google/gousb"
|
||||
"github.com/half2me/antgo/ant"
|
||||
@ -77,6 +78,7 @@ func ListenForTrainer(vendorId uint16, productId uint16, deviceNumber uint32,
|
||||
case events <- Event{
|
||||
Power: cur.InstantaneousPower(),
|
||||
Cadence: cur.InstantaneousCadence(),
|
||||
Now: time.Now(),
|
||||
}:
|
||||
default:
|
||||
logPrintf("ant: dropped event, buffer full\n")
|
||||
|
||||
@ -56,7 +56,7 @@ func ExposeBluetooth(events <-chan Event) {
|
||||
lastUpdate := time.Now()
|
||||
var elapsedTicks float64
|
||||
for event := range events {
|
||||
now := time.Now()
|
||||
now := event.Now
|
||||
deltaT := now.Sub(lastUpdate).Seconds()
|
||||
lastUpdate = now
|
||||
|
||||
@ -82,7 +82,7 @@ func ExposeBluetooth(events <-chan Event) {
|
||||
if _, err := powerChar.Write(payload); err != nil {
|
||||
logPrintf("bt: failed to write power characteristic: %v\n", err)
|
||||
}
|
||||
logPrintf("bt: watts: %d rpm: %.0f completedRevs: %.0f lastRevTime: %.0f processingTime: %v\n",
|
||||
logPrintf("bt: watts: %d rpm: %.0f completedRevs: %.0f lastRevTime: %.0f processingDelay: %v\n",
|
||||
watts, rpm, completedRevs, lastCompletedRev, time.Now().Sub(now))
|
||||
}
|
||||
logMsg("bt: BLE advertising stopped")
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
type Event struct {
|
||||
Power uint16
|
||||
Cadence uint8
|
||||
Now time.Time
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user