Show all points for day
This commit is contained in:
@@ -142,16 +142,16 @@ final class BluetoothClient: ObservableObject {
|
||||
guard let deviceInfo else {
|
||||
return
|
||||
}
|
||||
guard !deviceInfo.hasDeviceStartTimeSet || deviceInfo.clockOffset > minimumOffsetToUpdateDeviceClock else {
|
||||
guard !deviceInfo.hasDeviceStartTimeSet || abs(deviceInfo.clockOffset) > minimumOffsetToUpdateDeviceClock else {
|
||||
return
|
||||
}
|
||||
|
||||
guard !openRequests.contains(where: { if case .setDeviceStartTime = $0 { return true }; return false }) else {
|
||||
return
|
||||
}
|
||||
let time = deviceInfo.deviceStartTime.seconds
|
||||
let time = deviceInfo.calculatedDeviceStartTime.seconds
|
||||
addRequest(.setDeviceStartTime(deviceStartTimeSeconds: time))
|
||||
log.info("Setting device start time to \(time) s (\(Date().seconds) current)")
|
||||
log.info("Setting device start time to \(time) s (correcting offset of \(Int(deviceInfo.clockOffset)) s)")
|
||||
}
|
||||
|
||||
// MARK: Data transfer
|
||||
|
@@ -52,9 +52,14 @@ struct DeviceInfo {
|
||||
|
||||
var clockOffset: TimeInterval {
|
||||
// Measurements are performed on device start (-1) and also count next measurement (+1)
|
||||
let nextMeasurementTime = deviceStartTime.adding(seconds: (totalNumberOfMeasurements) * measurementInterval)
|
||||
let nextMeasurementTime = deviceStartTime.adding(seconds: totalNumberOfMeasurements * measurementInterval)
|
||||
return nextMeasurement.timeIntervalSince(nextMeasurementTime)
|
||||
}
|
||||
|
||||
var calculatedDeviceStartTime: Date {
|
||||
let runtime = totalNumberOfMeasurements * measurementInterval
|
||||
return nextMeasurement.adding(seconds: -runtime)
|
||||
}
|
||||
}
|
||||
|
||||
extension DeviceInfo {
|
||||
|
Reference in New Issue
Block a user