Skip to content

Commit

Permalink
limit BG readings to absolute maximum of 600 before processing by RVC
Browse files Browse the repository at this point in the history
  • Loading branch information
paulplant committed Jan 7, 2023
1 parent 904778f commit 3109e01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xdrip/Calibration/NoCalibrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class NoCalibrator: Calibrator {

findSlope(for: bgReading, last2Readings: &last3Readings)

// just do a quick sanity check to ensure that we limit any very high values that come through unfiltered such as can occur with Libre 2 output immediately after start-up/insertion.
// this will limit it to around 600 maximum. Most errant readings are 600 > bg > 5000.
// we purposefully limit to 600 and not to 400 as Libre, unlike Dexcom, can send values between 400 and 600 and although we won't display them without "HIGH", we can use them to show the delta and trend to help the user
bgReading.calculatedValue = min(ConstantsCalibrationAlgorithms.maximumBgReadingCalculatedValueLimit, bgReading.calculatedValue)

return bgReading
}

Expand Down
1 change: 1 addition & 0 deletions xdrip/Constants/ConstantsCalibrationAlgorithms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ enum ConstantsCalibrationAlgorithms {
// minimum and maxium values for a reading
static let minimumBgReadingCalculatedValue = 39.0
static let maximumBgReadingCalculatedValue = 400.0
static let maximumBgReadingCalculatedValueLimit = 600.0
static let bgReadingErrorValue = 38.0
}

0 comments on commit 3109e01

Please sign in to comment.