瀏覽代碼

Fix threshold settings values and storage

Deniz Cengiz 1 年之前
父節點
當前提交
aaf195b231

+ 1 - 1
FreeAPS/Resources/json/defaults/preferences.json

@@ -49,6 +49,6 @@
   "tddAdjBasal" : false,
   "enableSMB_high_bg" : false,
   "enableSMB_high_bg_target" : 110,
-  "threshold_setting" : 65,
+  "threshold_setting" : 60,
   "updateInterval" : 20
 }

+ 1 - 1
FreeAPS/Sources/Models/DecimalPickerSettings.swift

@@ -129,7 +129,7 @@ struct DecimalPickerSettings {
         max: 200,
         type: PickerSetting.PickerSettingType.glucose
     )
-    var threshold_setting = PickerSetting(value: 65, step: 1, min: 65, max: 100, type: PickerSetting.PickerSettingType.glucose)
+    var threshold_setting = PickerSetting(value: 60, step: 1, min: 60, max: 120, type: PickerSetting.PickerSettingType.glucose)
     var updateInterval = PickerSetting(value: 20, step: 5, min: 1, max: 60, type: PickerSetting.PickerSettingType.minute)
     var delay = PickerSetting(value: 20, step: 5, min: 5, max: 60, type: PickerSetting.PickerSettingType.minute)
     var minuteInterval = PickerSetting(value: 20, step: 5, min: 5, max: 60, type: PickerSetting.PickerSettingType.minute)

+ 1 - 1
FreeAPS/Sources/Models/Preferences.swift

@@ -52,7 +52,7 @@ struct Preferences: JSON {
     var tddAdjBasal: Bool = false
     var enableSMB_high_bg: Bool = false
     var enableSMB_high_bg_target: Decimal = 110
-    var threshold_setting: Decimal = 65
+    var threshold_setting: Decimal = 60
     var updateInterval: Decimal = 20
 }
 

+ 3 - 10
FreeAPS/Sources/Modules/DynamicSettings/DynamicSettingsStateModel.swift

@@ -12,7 +12,7 @@ extension DynamicSettings {
         @Published var adjustmentFactorSigmoid: Decimal = 0.5
         @Published var weightPercentage: Decimal = 0.65
         @Published var tddAdjBasal: Bool = false
-        @Published var threshold_setting: Decimal = 65
+        @Published var threshold_setting: Decimal = 60
         @Published var units: GlucoseUnits = .mgdL
 
         var preferences: Preferences {
@@ -37,18 +37,11 @@ extension DynamicSettings {
                 preferences.sigmoid == sigmoid &&
                 preferences.adjustmentFactorSigmoid == adjustmentFactorSigmoid &&
                 preferences.tddAdjBasal == tddAdjBasal &&
-                preferences.threshold_setting == convertBack(threshold_setting) &&
+                preferences.threshold_setting == threshold_setting &&
                 preferences.useNewFormula == useNewFormula &&
                 preferences.weightPercentage == weightPercentage
         }
 
-        func convertBack(_ glucose: Decimal) -> Decimal {
-            if units == .mmolL {
-                return glucose.asMgdL
-            }
-            return glucose
-        }
-
         func saveIfChanged() {
             if !unChanged {
                 var newSettings = storage.retrieve(OpenAPS.Settings.preferences, as: Preferences.self) ?? Preferences()
@@ -57,7 +50,7 @@ extension DynamicSettings {
                 newSettings.sigmoid = sigmoid
                 newSettings.adjustmentFactorSigmoid = adjustmentFactorSigmoid
                 newSettings.tddAdjBasal = tddAdjBasal
-                newSettings.threshold_setting = convertBack(threshold_setting)
+                newSettings.threshold_setting = threshold_setting
                 newSettings.useNewFormula = useNewFormula
                 newSettings.weightPercentage = weightPercentage
                 newSettings.timestamp = Date()