Explorar o código

Low bg alarm in progress

Jonas Björkert hai 1 ano
pai
achega
e8b9202224

+ 2 - 2
LoopFollow/Alarm/Alarm.swift

@@ -43,8 +43,8 @@ struct Alarm: Identifiable, Codable, Equatable {
     /// If a delta alarm is only active below a bg, that bg is stored in threshold
     var delta: Double?
 
-    /// Number of consecutive 5‑min readings that must satisfy the alarm criteria
-    var consecutiveReadings: Int?
+    /// Number of minutes that must satisfy the alarm criteria
+    var persistentMinutes: Int?
 
     /// Size of window to observe values, for example battery drop of x within this number of minutes,
     var monitoringWindow: Int?

+ 1 - 1
LoopFollow/Alarm/AlarmEditing/Components/AlarmEditorFields.swift

@@ -34,7 +34,7 @@ struct AlarmStepperSection: View {
     var body: some View {
         Section(
           header: Text(title),
-          footer: Text("\(title) in \(Int(range.lowerBound))–\(Int(range.upperBound)) \(unitLabel)")
+          footer: Text("Set \(title), \(Int(range.lowerBound))–\(Int(range.upperBound)) \(unitLabel)")
         ) {
             Stepper(
                 "\(title): \(Int(value)) \(unitLabel)",

+ 12 - 0
LoopFollow/Alarm/AlarmEditing/Editors/LowBgAlarmEditor.swift

@@ -27,7 +27,19 @@ struct LowBgAlarmEditor: View {
             )
 
             AlarmStepperSection(
+                title: "Persistent",
+                range: 0...120,
+                step: 5,
+                unitLabel: alarm.type.timeUnit.label,
+                value: Binding(
+                    get: { Double(alarm.persistentMinutes ?? 0) },
+                    set: { alarm.persistentMinutes = Int($0) }
+                )
+            )
+
+            AlarmStepperSection(
                 title: "Predictive",
+                //footer: include this manu minutes of prediction
                 range: 0...60,
                 step: 5,
                 unitLabel: alarm.type.timeUnit.label,

+ 2 - 2
LoopFollow/Task/AlarmTask.swift

@@ -21,10 +21,10 @@ extension MainViewController {
         DispatchQueue.main.async {
             let alarmData = AlarmData(
                 bgReadings: self.bgData
-                    .suffix(5)
+                    .suffix(24)
                     .map { GlucoseValue(sgv: $0.sgv, date: Date(timeIntervalSince1970: $0.date)) }, /// These are oldest .. newest
                 predictionData: self.predictionData
-                    .prefix(5)
+                    .prefix(12)
                     .map { GlucoseValue(sgv: $0.sgv, date: Date(timeIntervalSince1970: $0.date)) }, /// These are oldest .. newest, Predictions not currently available for Trio
                 expireDate: Storage.shared.expirationDate.value
             )