Просмотр исходного кода

Allow looping when HIGH (#259)

**Allow looping when HIGH**

* Allow lflat glucose when CGM readings are HIGH (but disable SM and high temps) for IOB computations etc.
* Display HIGH when CGM reading is HIGH.
* Display real glucose when entering capillary glucose.
* Allow (capillary readings over HIGH for normal looping.
* Display in Enacted pop-up.
* Display warning in same pop-up
* Disable SMB and high temps in oref2 code when reading is HIGH (potential invalid CGM reading).
Jon B Mårtensson 2 лет назад
Родитель
Сommit
5f4e1a958e

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
FreeAPS/Resources/javascript/bundle/determine-basal.js


+ 7 - 4
FreeAPS/Sources/APS/APSManager.swift

@@ -342,10 +342,13 @@ final class BaseAPSManager: APSManager, Injectable {
             return Just(false).eraseToAnyPublisher()
         }
 
-        guard glucoseStorage.isGlucoseNotFlat() else {
-            debug(.apsManager, "Glucose data is too flat")
-            processError(APSError.glucoseError(message: "Glucose data is too flat"))
-            return Just(false).eraseToAnyPublisher()
+        // Only let glucose be flat when 400 mg/dl
+        if (glucoseStorage.recent().last?.glucose ?? 100) != 400 {
+            guard glucoseStorage.isGlucoseNotFlat() else {
+                debug(.apsManager, "Glucose data is too flat")
+                processError(APSError.glucoseError(message: "Glucose data is too flat"))
+                return Just(false).eraseToAnyPublisher()
+            }
         }
 
         let now = Date()

+ 1 - 1
FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -76,7 +76,7 @@ extension DataTable {
                         }
                         label: { Text("Save") }
                             .frame(maxWidth: .infinity, alignment: .trailing)
-                            .disabled(state.manualGlcuose < limitLow || state.manualGlcuose > limitHigh)
+                        // .disabled(state.manualGlcuose < limitLow || state.manualGlcuose > limitHigh)
 
                     }.padding(20)
                 }

+ 1 - 1
FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift

@@ -48,7 +48,7 @@ struct CurrentGlucoseView: View {
         VStack(alignment: .center) {
             HStack {
                 Text(
-                    recentGlucose?.glucose
+                    (recentGlucose?.glucose ?? 100) == 400 ? "HIGH" : recentGlucose?.glucose
                         .map {
                             glucoseFormatter
                                 .string(from: Double(units == .mmolL ? $0.asMmolL : Decimal($0)) as NSNumber)! }

+ 3 - 0
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -618,6 +618,9 @@ extension Home {
                         .padding(.bottom, 4)
                         .padding(.top, 8)
                     Text(errorMessage).font(.caption).foregroundColor(.loopRed)
+                } else if let suggestion = state.suggestion, (suggestion.bg ?? 100) == 400 {
+                    Text("Invalid CGM reading (HIGH).").font(.callout).bold().foregroundColor(.loopRed).padding(.top, 8)
+                    Text("SMBs and High Temps Disabled.").font(.caption).foregroundColor(.white).padding(.bottom, 4)
                 }
             }
         }