Explorar el Código

Auto-ISF preferences updates

Jon Mårtensson hace 4 años
padre
commit
8b6c4bbd25

+ 14 - 16
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -33,22 +33,20 @@ extension Home {
             HStack(alignment: .bottom) {
             HStack(alignment: .bottom) {
                 Spacer()
                 Spacer()
                 VStack(alignment: .leading, spacing: 12) {
                 VStack(alignment: .leading, spacing: 12) {
-                    // HStack {
-                    // Text("").font(.caption2).foregroundColor(.secondary) // Was "IOB"
-                    Text(
-                        (numberFormatter.string(from: (viewModel.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
-                            NSLocalizedString(" U", comment: "Insulin unit")
-                    )
-                    .font(.system(size: 12, weight: .bold))
-                    // }
-                    // HStack {
-                    // Text("").font(.caption2).foregroundColor(.secondary) // Was "COB"
-                    Text(
-                        (numberFormatter.string(from: (viewModel.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
-                            NSLocalizedString(" g", comment: "gram of carbs")
-                    )
-                    .font(.system(size: 12, weight: .bold))
-                    // }
+                    HStack {
+                        Text(
+                            (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
+                                NSLocalizedString(" U", comment: "Insulin unit")
+                        )
+                        .font(.system(size: 12, weight: .bold))
+                    }
+                    HStack {
+                        Text(
+                            (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
+                                NSLocalizedString(" g", comment: "gram of carbs")
+                        )
+                        .font(.system(size: 12, weight: .bold))
+                    }
                 }
                 }
                 Spacer()
                 Spacer()
 
 

+ 52 - 0
FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorStateModel.swift

@@ -402,6 +402,54 @@ extension PreferencesEditor {
                 )
                 )
             ]
             ]
 
 
+            let autoisfSettings = [
+                Field(
+                    displayName: "Enable AutoISF",
+                    type: .boolean(keypath: \.autoisf),
+                    infoText: NSLocalizedString(
+                        "Defaults to false. Adapt ISF when glucose is stuck at high levels, only works without COB.\n\nRead up on:\nhttps://github.com/ga-zelle/autoISF/tree/2.8.2",
+                        comment: "Enable AutoISF"
+                    ),
+                    settable: self
+                ),
+                Field(
+                    displayName: "AutoISF HourlyMaxChange",
+                    type: .decimal(keypath: \.autoISFhourlyChange),
+                    infoText: NSLocalizedString(
+                        "Defaults to false. Rate at which autoISF grows per hour assuming bg is twice target. When value = 1.0, ISF is reduced to 50% after 1 hour of BG at 2x target.",
+                        comment: "AutoISF HourlyMaxChange"
+                    ),
+                    settable: self
+                ),
+                Field(
+                    displayName: "AutoISF Max",
+                    type: .decimal(keypath: \.autoISFmax),
+                    infoText: NSLocalizedString(
+                        "Multiplier cap on how high the autoISF ratio can be and therefore how low it can adjust ISF.",
+                        comment: "AutoISF Max"
+                    ),
+                    settable: self
+                ),
+                Field(
+                    displayName: "SMB Max RangeExtension",
+                    type: .decimal(keypath: \.smbMaxRangeExtension),
+                    infoText: NSLocalizedString(
+                        "Default value: 1. This is another key OpenAPS safety cap, and specifies by what factor you can exceed the regular 120 maxSMB/maxUAM minutes. Increase this experimental value slowly and with caution.",
+                        comment: "SMB Max RangeExtension"
+                    ),
+                    settable: self
+                ),
+                Field(
+                    displayName: "SMB DeliveryRatio",
+                    type: .decimal(keypath: \.smbDeliveryRatio),
+                    infoText: NSLocalizedString(
+                        "Default value: 0.5 This is another key OpenAPS safety cap, and specifies what share of the total insulin required can be delivered as SMB. This is to prevent people from getting into dangerous territory by setting SMB requests from the caregivers phone at the same time. Increase this experimental value slowly and with caution.",
+                        comment: "SMB DeliveryRatio"
+                    ),
+                    settable: self
+                )
+            ]
+
             sections = [
             sections = [
                 FieldSection(
                 FieldSection(
                     displayName: NSLocalizedString("OpenAPS main settings", comment: "OpenAPS main settings"), fields: mainFields
                     displayName: NSLocalizedString("OpenAPS main settings", comment: "OpenAPS main settings"), fields: mainFields
@@ -416,6 +464,10 @@ extension PreferencesEditor {
                 FieldSection(
                 FieldSection(
                     displayName: NSLocalizedString("OpenAPS other settings", comment: "OpenAPS other settings"),
                     displayName: NSLocalizedString("OpenAPS other settings", comment: "OpenAPS other settings"),
                     fields: otherSettings
                     fields: otherSettings
+                ),
+                FieldSection(
+                    displayName: NSLocalizedString("Auto-ISF settings", comment: "Auto-ISF settings"),
+                    fields: autoisfSettings
                 )
                 )
             ]
             ]
         }
         }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 498
FreeAPS/Sources/Modules/PreferencesEditor/PreferencesEditorViewModel.swift