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

Add separate setting for sigmoid adjustment factor

Mike Plante 2 лет назад
Родитель
Сommit
a775371488

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

@@ -39,7 +39,8 @@
   "noisyCGMTargetMultiplier" : 1.3,
   "suspend_zeros_iob" : false,
   "maxDelta_bg_threshold" : 0.2,
-  "adjustmentFactor" : 0.5,
+  "adjustmentFactor" : 0.8,
+  "adjustmentFactorSigmoid" : 0.5,
   "sigmoid" : false,
   "enableDynamicCR" : false,
   "useNewFormula" : false,

+ 1 - 1
FreeAPS/Sources/APS/APSManager.swift

@@ -939,7 +939,7 @@ final class BaseAPSManager: APSManager, Injectable {
                 } else if preferences.useNewFormula, !preferences.sigmoid,!preferences.enableDynamicCR {
                     algo_ = "Dynamic ISF: Logarithmic"
                 }
-                let af = preferences.adjustmentFactor
+                let af = preferences.sigmoid ? preferences.adjustmentFactorSigmoid : preferences.adjustmentFactor
                 let insulin_type = preferences.curve
                 let buildDate = Bundle.main.buildDate
                 let version = Bundle.main.releaseVersionNumber

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

@@ -42,7 +42,8 @@ struct Preferences: JSON {
     var suspendZerosIOB: Bool = false
     var timestamp: Date?
     var maxDeltaBGthreshold: Decimal = 0.2
-    var adjustmentFactor: Decimal = 0.5
+    var adjustmentFactor: Decimal = 0.8
+    var adjustmentFactorSigmoid: Decimal = 0.5
     var sigmoid: Bool = false
     var enableDynamicCR: Bool = false
     var useNewFormula: Bool = false
@@ -98,6 +99,7 @@ extension Preferences {
         case suspendZerosIOB = "suspend_zeros_iob"
         case maxDeltaBGthreshold = "maxDelta_bg_threshold"
         case adjustmentFactor
+        case adjustmentFactorSigmoid
         case sigmoid
         case enableDynamicCR
         case useNewFormula

+ 13 - 1
FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift

@@ -108,7 +108,7 @@ extension PreferencesEditor {
                     displayName: NSLocalizedString("Adjustment Factor", comment: "Adjust Dynamic ISF constant"),
                     type: .decimal(keypath: \.adjustmentFactor),
                     infoText: NSLocalizedString(
-                        "Adjust Dynamic ratios by a constant. Default is 0.5. The higher the value, the larger the correction of your ISF will be for a high or a low BG. Maximum correction is determined by the Autosens min/max settings. For Sigmoid function an adjustment factor of 0.4 - 0.5 is recommended to begin with. For the logaritmic formula threre is less consensus, but starting with 0.5 - 0.8 is more appropiate for most users",
+                        "Adjust Dynamic ratios by a constant. Default is 0.8. The higher the value, the larger the correction of your ISF will be for a high or a low BG. Maximum correction is determined by the Autosens min/max settings.",
                         comment: "Adjust Dynamic ISF constant"
                     ),
                     settable: self
@@ -124,6 +124,18 @@ extension PreferencesEditor {
                 ),
                 Field(
                     displayName: NSLocalizedString(
+                        "Sigmoid Adjustment Factor",
+                        comment: "Adjust Dynamic ISF constant for Sigmoid"
+                    ),
+                    type: .decimal(keypath: \.adjustmentFactorSigmoid),
+                    infoText: NSLocalizedString(
+                        "Adjust Dynamic ratios by a constant. Default is 0.5. The higher the value, the larger the correction of your ISF will be for a high or a low BG. Maximum correction is determined by the Autosens min/max settings.",
+                        comment: "Adjust Dynamic ISF constant for Sigmoid"
+                    ),
+                    settable: self
+                ),
+                Field(
+                    displayName: NSLocalizedString(
                         "Weighted Average of TDD. Weight of past 24 hours:",
                         comment: "Weight of past 24 hours of insulin"
                     ),