add "warming up until xx:xx" to Dexcom bluetoothPeripheral screen

- set to display "warming up until xx:xx" until 120 minutes after the sensor session was started in the transmitter)
- most Dexcom users know this but it looks useful in the Libre 2 BLE UI, so we can just implement it here too
This commit is contained in:
Paul Plant 2023-02-07 19:39:16 +01:00
parent 49618e59a7
commit a830714ce6
2 changed files with 26 additions and 5 deletions

View File

@ -4,9 +4,13 @@ enum ConstantsMaster {
/// maximum age in seconds, of reading in alert flow. If age of latest reading is more than this number, then no alert check will be done
static let maximumBgReadingAgeForAlertsInSeconds = 240.0
/// minimum sensor warm-up time required for all sensors before allowing the app to process a BG reading
/// this will only be relevant for active sensors that hold a sensorAge value
/// some transmitters (such as Dexcom) enforce warm-up on the transmitter side before transmitting values
// minimum sensor warm-up time required for all transmitters/sensors before allowing the app to process a BG reading
// this will only be relevant for active sensors that hold a sensorAge value
/// warm-up time considered for all sensors/transmitters after starting (enforced globally by the app)
static let minimumSensorWarmUpRequiredInMinutes = 45.0
/// warm-up time enfoced by the Dexcom G6 transmitter. In this case, this will actually only be used for the UI to show when the sensor is reading.
static let minimumSensorWarmUpRequiredInMinutesDexcomG5G6 = 120.0
}

View File

@ -232,8 +232,25 @@ extension DexcomG5BluetoothPeripheralViewModel: BluetoothPeripheralViewModel {
var startDateString = ""
if let startDate = dexcomG5.sensorStartDate {
startDateString = dexcomG5.sensorStartDate?.toStringInUserLocale(timeStyle: .none, dateStyle: .short) ?? ""
startDateString += " (" + startDate.daysAndHoursAgo() + ")"
let sensorTimeInMinutes = -Int(startDate.timeIntervalSinceNow / 60)
if sensorTimeInMinutes < Int(ConstantsMaster.minimumSensorWarmUpRequiredInMinutesDexcomG5G6) {
// the Dexcom is still in the transmitter forced warm-up time so let's make it clear to the user
let sensorReadyDateTime = startDate.addingTimeInterval(ConstantsMaster.minimumSensorWarmUpRequiredInMinutesDexcomG5G6 * 60)
startDateString = Texts_BluetoothPeripheralView.warmingUpUntil + " " + sensorReadyDateTime.toStringInUserLocale(timeStyle: .short, dateStyle: .none)
} else {
// Dexcom is not warming up so let's show the sensor start date and age
startDateString = startDate.toStringInUserLocale(timeStyle: .none, dateStyle: .short)
startDateString += " (" + startDate.daysAndHoursAgo() + ")"
}
}
cell.textLabel?.text = Texts_BluetoothPeripheralView.sensorStartDate