浏览代码

Relocate 3 settings & Update Max Bolus Hint

Moves the following:
- SMB Delivery Ratio (SMB Settings -> Additionals)
- Minimum Safety Threshold (Dynamic Settings -> Units and Limits)
- SMB Interval (SMB Settings -> Additionals)

Updates Max Bolus hint

Includes Localization updates
tmhastings 1 年之前
父节点
当前提交
ab142e7e28

+ 4 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -173902,6 +173902,7 @@
       }
     },
     "This is the maximum bolus allowed to be delivered at one time. This limits manual and automatic bolus." : {
+      "extractionState" : "stale",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -174001,6 +174002,9 @@
         }
       }
     },
+    "This is the maximum bolus allowed to be delivered at one time. This only limits manual boluses and does not limit SMBs." : {
+
+    },
     "This is the minimum number of minutes since the last SMB or manual bolus before Trio will permit an automated SMB." : {
       "localizations" : {
         "bg" : {

+ 4 - 0
Trio/Sources/Modules/AlgorithmAdvancedSettings/AlgorithmAdvancedSettingsStateModel.swift

@@ -22,6 +22,8 @@ extension AlgorithmAdvancedSettings {
         @Published var remainingCarbsCap: Decimal = 90
         @Published var noisyCGMTargetMultiplier: Decimal = 1.3
         @Published var insulinActionCurve: Decimal = 10
+        @Published var smbDeliveryRatio: Decimal = 0.5
+        @Published var smbInterval: Decimal = 3
 
         var pumpSettings: PumpSettings {
             provider.settings()
@@ -45,6 +47,8 @@ extension AlgorithmAdvancedSettings {
             subscribePreferencesSetting(\.remainingCarbsCap, on: $remainingCarbsCap) { remainingCarbsCap = $0 }
             subscribePreferencesSetting(\.noisyCGMTargetMultiplier, on: $noisyCGMTargetMultiplier) {
                 noisyCGMTargetMultiplier = $0 }
+            subscribePreferencesSetting(\.smbDeliveryRatio, on: $smbDeliveryRatio) { smbDeliveryRatio = $0 }
+            subscribePreferencesSetting(\.smbInterval, on: $smbInterval) { smbInterval = $0 }
 
             insulinActionCurve = pumpSettings.insulinActionCurve
         }

+ 52 - 0
Trio/Sources/Modules/AlgorithmAdvancedSettings/View/AlgorithmAdvancedSettingsRootView.swift

@@ -251,6 +251,58 @@ extension AlgorithmAdvancedSettings {
                 )
 
                 SettingInputSection(
+                    decimalValue: $state.smbDeliveryRatio,
+                    booleanValue: $booleanPlaceholder,
+                    shouldDisplayHint: $shouldDisplayHint,
+                    selectedVerboseHint: Binding(
+                        get: { selectedVerboseHint },
+                        set: {
+                            selectedVerboseHint = $0.map { AnyView($0) }
+                            hintLabel = String(localized: "SMB Delivery Ratio", comment: "SMB Delivery Ratio")
+                        }
+                    ),
+                    units: state.units,
+                    type: .decimal("smbDeliveryRatio"),
+                    label: String(localized: "SMB Delivery Ratio", comment: "SMB Delivery Ratio"),
+                    miniHint: String(localized: "Percentage of calculated insulin required that is given as SMB."),
+                    verboseHint:
+                    VStack(alignment: .leading, spacing: 10) {
+                        Text("Default: 50%").bold()
+                        Text(
+                            "Once the total insulin required is calculated, this safety limit specifies what percentage of the insulin required can be delivered as an SMB."
+                        )
+                        Text(
+                            "Due to SMBs potentially occurring every 5 minutes with each loop cycle, it is important to set this value to a reasonable level that allows Trio to safely zero temp should dosing needs suddenly change. Increase this value with caution."
+                        )
+                        Text("Note: Allowed range is 30 - 70%")
+                    }
+                )
+
+                SettingInputSection(
+                    decimalValue: $state.smbInterval,
+                    booleanValue: $booleanPlaceholder,
+                    shouldDisplayHint: $shouldDisplayHint,
+                    selectedVerboseHint: Binding(
+                        get: { selectedVerboseHint },
+                        set: {
+                            selectedVerboseHint = $0.map { AnyView($0) }
+                            hintLabel = String(localized: "SMB Interval", comment: "SMB Interval")
+                        }
+                    ),
+                    units: state.units,
+                    type: .decimal("smbInterval"),
+                    label: String(localized: "SMB Interval", comment: "SMB Interval"),
+                    miniHint: String(localized: "Minimum minutes since the last SMB or manual bolus to allow an automated SMB."),
+                    verboseHint:
+                    VStack(alignment: .leading, spacing: 10) {
+                        Text("Default: 3 min").bold()
+                        Text(
+                            "This is the minimum number of minutes since the last SMB or manual bolus before Trio will permit an automated SMB."
+                        )
+                    }
+                )
+
+                SettingInputSection(
                     decimalValue: $state.min5mCarbimpact,
                     booleanValue: $booleanPlaceholder,
                     shouldDisplayHint: $shouldDisplayHint,

+ 0 - 2
Trio/Sources/Modules/DynamicSettings/DynamicSettingsStateModel.swift

@@ -34,7 +34,6 @@ extension DynamicSettings {
         @Published var adjustmentFactorSigmoid: Decimal = 0.5
         @Published var weightPercentage: Decimal = 0.65
         @Published var tddAdjBasal: Bool = false
-        @Published var threshold_setting: Decimal = 60
 
         @ObservedObject var pickerSettingsProvider = PickerSettingsProvider.shared
 
@@ -58,7 +57,6 @@ extension DynamicSettings {
             subscribePreferencesSetting(\.adjustmentFactorSigmoid, on: $adjustmentFactorSigmoid) { adjustmentFactorSigmoid = $0 }
             subscribePreferencesSetting(\.weightPercentage, on: $weightPercentage) { weightPercentage = $0 }
             subscribePreferencesSetting(\.tddAdjBasal, on: $tddAdjBasal) { tddAdjBasal = $0 }
-            subscribePreferencesSetting(\.threshold_setting, on: $threshold_setting) { threshold_setting = $0 }
 
             Task {
                 do {

+ 0 - 47
Trio/Sources/Modules/DynamicSettings/View/DynamicSettingsRootView.swift

@@ -261,53 +261,6 @@ extension DynamicSettings {
                         },
                         headerText: String(localized: "Dynamic-dependent Features")
                     )
-
-                    SettingInputSection(
-                        decimalValue: $state.threshold_setting,
-                        booleanValue: $booleanPlaceholder,
-                        shouldDisplayHint: $shouldDisplayHint,
-                        selectedVerboseHint: Binding(
-                            get: { selectedVerboseHint },
-                            set: {
-                                selectedVerboseHint = $0.map { AnyView($0) }
-                                hintLabel = String(localized: "Minimum Safety Threshold")
-                            }
-                        ),
-                        units: state.units,
-                        type: .decimal("threshold_setting"),
-                        label: String(localized: "Minimum Safety Threshold"),
-                        miniHint: String(localized: "Increase the safety threshold used to suspend insulin delivery."),
-                        verboseHint:
-                        VStack(alignment: .leading, spacing: 10) {
-                            Text("Default: Set by Algorithm").bold()
-                            Text(
-                                "Minimum Threshold Setting is, by default, determined by your set Glucose Target. This threshold automatically suspends insulin delivery if your glucose levels are forecasted to fall below this value. It’s designed to protect against hypoglycemia, particularly during sleep or other vulnerable times."
-                            )
-                            Text(
-                                "Trio will use the larger of the default setting calculation below and the value entered here."
-                            )
-                            VStack(alignment: .leading, spacing: 10) {
-                                VStack(alignment: .leading, spacing: 5) {
-                                    Text("The default setting is based on this calculation:").bold()
-                                    Text("TargetGlucose - 0.5 × (TargetGlucose - 40)")
-                                }
-                                VStack(alignment: .leading, spacing: 5) {
-                                    Text(
-                                        "If your glucose target is \(state.units == .mgdL ? "110" : 110.formattedAsMmolL) \(state.units.rawValue), Trio will use a safety threshold of \(state.units == .mgdL ? "75" : 75.formattedAsMmolL) \(state.units.rawValue), unless you set Minimum Safety Threshold to something > \(state.units == .mgdL ? "75" : 75.formattedAsMmolL) \(state.units.rawValue)."
-                                    )
-                                    Text(
-                                        "\(state.units == .mgdL ? "110" : 110.formattedAsMmolL) - 0.5 × (\(state.units == .mgdL ? "110" : 110.formattedAsMmolL) - \(state.units == .mgdL ? "40" : 40.formattedAsMmolL)) = \(state.units == .mgdL ? "75" : 75.formattedAsMmolL)"
-                                    )
-                                }
-                                Text(
-                                    "This setting is limited to values between \(state.units == .mgdL ? "60" : 60.formattedAsMmolL) - \(state.units == .mgdL ? "120" : 120.formattedAsMmolL) \(state.units.rawValue)"
-                                )
-                                Text(
-                                    "Note: Basal may be resumed if there is negative IOB and glucose is rising faster than the forecast."
-                                )
-                            }
-                        }
-                    )
                 }
             }
             .listSectionSpacing(sectionSpacing)

+ 2 - 0
Trio/Sources/Modules/GeneralSettings/UnitsLimitsSettingsStateModel.swift

@@ -14,6 +14,7 @@ extension UnitsLimitsSettings {
         @Published var maxIOB: Decimal = 0
         @Published var maxCOB: Decimal = 120
         @Published var hasChanged: Bool = false
+        @Published var threshold_setting: Decimal = 60
 
         var preferences: Preferences {
             settingsManager.preferences
@@ -31,6 +32,7 @@ extension UnitsLimitsSettings {
 
             subscribePreferencesSetting(\.maxIOB, on: $maxIOB) { maxIOB = $0 }
             subscribePreferencesSetting(\.maxCOB, on: $maxCOB) { maxCOB = $0 }
+            subscribePreferencesSetting(\.threshold_setting, on: $threshold_setting) { threshold_setting = $0 }
 
             maxBasal = pumpSettings.maxBasal
             maxBolus = pumpSettings.maxBolus

+ 48 - 1
Trio/Sources/Modules/GeneralSettings/View/UnitsLimitsSettingsRootView.swift

@@ -80,7 +80,7 @@ extension UnitsLimitsSettings {
                     VStack(alignment: .leading, spacing: 10) {
                         Text("Default: 10 units").bold()
                         Text(
-                            "This is the maximum bolus allowed to be delivered at one time. This limits manual and automatic bolus."
+                            "This is the maximum bolus allowed to be delivered at one time. This only limits manual boluses and does not limit SMBs."
                         )
                         Text("Most set this to their largest meal bolus. Then, adjust if needed.")
                         Text("If you attempt to request a bolus larger than this, the bolus will not be accepted.")
@@ -141,6 +141,53 @@ extension UnitsLimitsSettings {
                         Text("This is an important limit when UAM is ON.")
                     }
                 )
+
+                SettingInputSection(
+                    decimalValue: $state.threshold_setting,
+                    booleanValue: $booleanPlaceholder,
+                    shouldDisplayHint: $shouldDisplayHint,
+                    selectedVerboseHint: Binding(
+                        get: { selectedVerboseHint },
+                        set: {
+                            selectedVerboseHint = $0.map { AnyView($0) }
+                            hintLabel = String(localized: "Minimum Safety Threshold")
+                        }
+                    ),
+                    units: state.units,
+                    type: .decimal("threshold_setting"),
+                    label: String(localized: "Minimum Safety Threshold"),
+                    miniHint: String(localized: "Increase the safety threshold used to suspend insulin delivery."),
+                    verboseHint:
+                    VStack(alignment: .leading, spacing: 10) {
+                        Text("Default: Set by Algorithm").bold()
+                        Text(
+                            "Minimum Threshold Setting is, by default, determined by your set Glucose Target. This threshold automatically suspends insulin delivery if your glucose levels are forecasted to fall below this value. It’s designed to protect against hypoglycemia, particularly during sleep or other vulnerable times."
+                        )
+                        Text(
+                            "Trio will use the larger of the default setting calculation below and the value entered here."
+                        )
+                        VStack(alignment: .leading, spacing: 10) {
+                            VStack(alignment: .leading, spacing: 5) {
+                                Text("The default setting is based on this calculation:").bold()
+                                Text("TargetGlucose - 0.5 × (TargetGlucose - 40)")
+                            }
+                            VStack(alignment: .leading, spacing: 5) {
+                                Text(
+                                    "If your glucose target is \(state.units == .mgdL ? "110" : 110.formattedAsMmolL) \(state.units.rawValue), Trio will use a safety threshold of \(state.units == .mgdL ? "75" : 75.formattedAsMmolL) \(state.units.rawValue), unless you set Minimum Safety Threshold to something > \(state.units == .mgdL ? "75" : 75.formattedAsMmolL) \(state.units.rawValue)."
+                                )
+                                Text(
+                                    "\(state.units == .mgdL ? "110" : 110.formattedAsMmolL) - 0.5 × (\(state.units == .mgdL ? "110" : 110.formattedAsMmolL) - \(state.units == .mgdL ? "40" : 40.formattedAsMmolL)) = \(state.units == .mgdL ? "75" : 75.formattedAsMmolL)"
+                                )
+                            }
+                            Text(
+                                "This setting is limited to values between \(state.units == .mgdL ? "60" : 60.formattedAsMmolL) - \(state.units == .mgdL ? "120" : 120.formattedAsMmolL) \(state.units.rawValue)"
+                            )
+                            Text(
+                                "Note: Basal may be resumed if there is negative IOB and glucose is rising faster than the forecast."
+                            )
+                        }
+                    }
+                )
             }
             .listSectionSpacing(sectionSpacing)
             .sheet(isPresented: $shouldDisplayHint) {

+ 0 - 4
Trio/Sources/Modules/SMBSettings/SMBSettingsStateModel.swift

@@ -17,8 +17,6 @@ extension SMBSettings {
         @Published var enableSMB_high_bg: Bool = false
         @Published var enableSMB_high_bg_target: Decimal = 100
         @Published var maxSMBBasalMinutes: Decimal = 30
-        @Published var smbDeliveryRatio: Decimal = 0.5
-        @Published var smbInterval: Decimal = 3
         @Published var bolusIncrement: Decimal = 0.1 // get this from pump, dafuq?: Bool = false
         @Published var enableUAM: Bool = false
         @Published var maxUAMSMBBasalMinutes: Decimal = 30
@@ -37,8 +35,6 @@ extension SMBSettings {
             subscribePreferencesSetting(\.enableSMB_high_bg_target, on: $enableSMB_high_bg_target) {
                 enableSMB_high_bg_target = $0 }
             subscribePreferencesSetting(\.maxSMBBasalMinutes, on: $maxSMBBasalMinutes) { maxSMBBasalMinutes = $0 }
-            subscribePreferencesSetting(\.smbDeliveryRatio, on: $smbDeliveryRatio) { smbDeliveryRatio = $0 }
-            subscribePreferencesSetting(\.smbInterval, on: $smbInterval) { smbInterval = $0 }
             subscribePreferencesSetting(\.bolusIncrement, on: $bolusIncrement) { bolusIncrement = $0 }
             subscribePreferencesSetting(\.enableUAM, on: $enableUAM) { enableUAM = $0 }
             subscribePreferencesSetting(\.maxUAMSMBBasalMinutes, on: $maxUAMSMBBasalMinutes) { maxUAMSMBBasalMinutes = $0 }

+ 0 - 52
Trio/Sources/Modules/SMBSettings/View/SMBSettingsRootView.swift

@@ -343,58 +343,6 @@ extension SMBSettings {
                         Text("Note: This setting has a hard-coded cap of 40%")
                     }
                 )
-
-                SettingInputSection(
-                    decimalValue: $state.smbDeliveryRatio,
-                    booleanValue: $booleanPlaceholder,
-                    shouldDisplayHint: $shouldDisplayHint,
-                    selectedVerboseHint: Binding(
-                        get: { selectedVerboseHint },
-                        set: {
-                            selectedVerboseHint = $0.map { AnyView($0) }
-                            hintLabel = String(localized: "SMB Delivery Ratio", comment: "SMB Delivery Ratio")
-                        }
-                    ),
-                    units: state.units,
-                    type: .decimal("smbDeliveryRatio"),
-                    label: String(localized: "SMB Delivery Ratio", comment: "SMB Delivery Ratio"),
-                    miniHint: String(localized: "Percentage of calculated insulin required that is given as SMB."),
-                    verboseHint:
-                    VStack(alignment: .leading, spacing: 10) {
-                        Text("Default: 50%").bold()
-                        Text(
-                            "Once the total insulin required is calculated, this safety limit specifies what percentage of the insulin required can be delivered as an SMB."
-                        )
-                        Text(
-                            "Due to SMBs potentially occurring every 5 minutes with each loop cycle, it is important to set this value to a reasonable level that allows Trio to safely zero temp should dosing needs suddenly change. Increase this value with caution."
-                        )
-                        Text("Note: Allowed range is 30 - 70%")
-                    }
-                )
-
-                SettingInputSection(
-                    decimalValue: $state.smbInterval,
-                    booleanValue: $booleanPlaceholder,
-                    shouldDisplayHint: $shouldDisplayHint,
-                    selectedVerboseHint: Binding(
-                        get: { selectedVerboseHint },
-                        set: {
-                            selectedVerboseHint = $0.map { AnyView($0) }
-                            hintLabel = String(localized: "SMB Interval", comment: "SMB Interval")
-                        }
-                    ),
-                    units: state.units,
-                    type: .decimal("smbInterval"),
-                    label: String(localized: "SMB Interval", comment: "SMB Interval"),
-                    miniHint: String(localized: "Minimum minutes since the last SMB or manual bolus to allow an automated SMB."),
-                    verboseHint:
-                    VStack(alignment: .leading, spacing: 10) {
-                        Text("Default: 3 min").bold()
-                        Text(
-                            "This is the minimum number of minutes since the last SMB or manual bolus before Trio will permit an automated SMB."
-                        )
-                    }
-                )
             }
             .listSectionSpacing(sectionSpacing)
             .sheet(isPresented: $shouldDisplayHint) {