Skip to content

Commit

Permalink
fix #68 calculation of diff with previous value not correct if readin…
Browse files Browse the repository at this point in the history
…gs less than 5 minutes apart

Calculation of diff was taking the slope and then multiplied with 5 minutes. This seems not correct (strange nobody every noticed ?)

Probably because originally this was written for Dexcom transmitters, which give a reading every 5 minutes.

Although there too the diff is not correct if time difference > 5 minutes (10 minutes, 15, ...)

This changes will give another diff value in home screen, speak reading, watch, notification, text in alert.

Triggering of alerts is not impacted.
  • Loading branch information
JohanDegraeve committed Jan 29, 2020
1 parent d055d09 commit e62397c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xdrip/Core Data/classes/BgReading+CoreDataClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ public class BgReading: NSManagedObject {
return "???";
}

let value = currentSlope(previousBgReading: previousBgReading) * 5 * 60 * 1000;
// delta value recalculated aligned with time difference between previous and this reading
let value = currentSlope(previousBgReading: previousBgReading) * timeStamp.timeIntervalSince(previousBgReading.timeStamp) * 1000;

if(abs(value) > 100){
// a delta > 100 will not happen with real BG values -> problematic sensor data
return "ERR";
Expand Down

0 comments on commit e62397c

Please sign in to comment.