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

Merge branch 'core-data-sync-trio' into editTreatmentEntries

Deniz Cengiz 1 год назад
Родитель
Сommit
2f3fcfb2c7
25 измененных файлов с 137 добавлено и 132 удалено
  1. 13 11
      FreeAPS/Sources/APS/APSManager.swift
  2. 1 1
      FreeAPS/Sources/APS/DeviceDataManager.swift
  3. 2 1
      FreeAPS/Sources/APS/FetchGlucoseManager.swift
  4. 2 1
      FreeAPS/Sources/APS/Storage/GlucoseStorage.swift
  5. 1 0
      FreeAPS/Sources/Application/FreeAPSApp.swift
  6. 1 1
      FreeAPS/Sources/Models/DecimalPickerSettings.swift
  7. 1 1
      FreeAPS/Sources/Modules/Adjustments/View/Overrides/AddOverrideForm.swift
  8. 1 1
      FreeAPS/Sources/Modules/Adjustments/View/Overrides/EditOverrideForm.swift
  9. 11 9
      FreeAPS/Sources/Modules/BasalProfileEditor/View/BasalProfileEditorRootView.swift
  10. 1 1
      FreeAPS/Sources/Modules/BolusCalculatorConfig/View/BolusCalculatorConfigRootView.swift
  11. 3 1
      FreeAPS/Sources/Modules/CarbRatioEditor/View/CarbRatioEditorRootView.swift
  12. 1 4
      FreeAPS/Sources/Modules/Home/HomeStateModel+Setup/GlucoseTargetSetup.swift
  13. 1 0
      FreeAPS/Sources/Modules/Home/HomeStateModel.swift
  14. 1 1
      FreeAPS/Sources/Modules/Home/View/Chart/ChartElements/CarbView.swift
  15. 2 1
      FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift
  16. 1 1
      FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift
  17. 8 1
      FreeAPS/Sources/Modules/ISFEditor/View/ISFEditorRootView.swift
  18. 33 38
      FreeAPS/Sources/Modules/PumpConfig/View/PumpConfigRootView.swift
  19. 1 1
      FreeAPS/Sources/Modules/SMBSettings/View/SMBSettingsRootView.swift
  20. 2 7
      FreeAPS/Sources/Modules/Stat/View/StatsView.swift
  21. 22 22
      FreeAPS/Sources/Modules/TargetsEditor/View/TargetsEditorRootView.swift
  22. 12 10
      FreeAPS/Sources/Modules/Treatments/View/TreatmentsRootView.swift
  23. 14 16
      FreeAPS/Sources/Modules/WatchConfig/View/WatchConfigGarminView.swift
  24. 1 1
      Model/Classes+Properties/OpenAPS_Battery+CoreDataProperties.swift
  25. 1 1
      Model/TrioCoreDataPersistentContainer.xcdatamodeld/TrioCoreDataPersistentContainer.xcdatamodel/contents

+ 13 - 11
FreeAPS/Sources/APS/APSManager.swift

@@ -1168,16 +1168,18 @@ final class BaseAPSManager: APSManager, Injectable {
             let hbA1cDisplayUnit = self.settingsManager.settings.hbA1cDisplayUnit
             let hbA1cDisplayUnit = self.settingsManager.settings.hbA1cDisplayUnit
 
 
             let hbs = Durations(
             let hbs = Durations(
-                day: ((units == .mmolL && hbA1cDisplayUnit == .mmolMol) || (units == .mgdL && hbA1cDisplayUnit == .percent)) ?
-                    self.roundDecimal(Decimal(oneDayGlucose.ifcc), 1) : self.roundDecimal(Decimal(oneDayGlucose.ngsp), 1),
-                week: ((units == .mmolL && hbA1cDisplayUnit == .mmolMol) || (units == .mgdL && hbA1cDisplayUnit == .percent)) ?
-                    self.roundDecimal(Decimal(sevenDaysGlucose.ifcc), 1) : self
-                    .roundDecimal(Decimal(sevenDaysGlucose.ngsp), 1),
-                month: ((units == .mmolL && hbA1cDisplayUnit == .mmolMol) || (units == .mgdL && hbA1cDisplayUnit == .percent)) ?
-                    self.roundDecimal(Decimal(thirtyDaysGlucose.ifcc), 1) : self
-                    .roundDecimal(Decimal(thirtyDaysGlucose.ngsp), 1),
-                total: ((units == .mmolL && hbA1cDisplayUnit == .mmolMol) || (units == .mgdL && hbA1cDisplayUnit == .percent)) ?
-                    self.roundDecimal(Decimal(totalDaysGlucose.ifcc), 1) : self.roundDecimal(Decimal(totalDaysGlucose.ngsp), 1)
+                day: hbA1cDisplayUnit == .mmolMol ?
+                    self.roundDecimal(Decimal(oneDayGlucose.ifcc), 1) :
+                    self.roundDecimal(Decimal(oneDayGlucose.ngsp), 1),
+                week: hbA1cDisplayUnit == .mmolMol ?
+                    self.roundDecimal(Decimal(sevenDaysGlucose.ifcc), 1) :
+                    self.roundDecimal(Decimal(sevenDaysGlucose.ngsp), 1),
+                month: hbA1cDisplayUnit == .mmolMol ?
+                    self.roundDecimal(Decimal(thirtyDaysGlucose.ifcc), 1) :
+                    self.roundDecimal(Decimal(thirtyDaysGlucose.ngsp), 1),
+                total: hbA1cDisplayUnit == .mmolMol ?
+                    self.roundDecimal(Decimal(totalDaysGlucose.ifcc), 1) :
+                    self.roundDecimal(Decimal(totalDaysGlucose.ngsp), 1)
             )
             )
 
 
             var oneDay_: (TIR: Double, hypos: Double, hypers: Double, normal_: Double) = (0.0, 0.0, 0.0, 0.0)
             var oneDay_: (TIR: Double, hypos: Double, hypers: Double, normal_: Double) = (0.0, 0.0, 0.0, 0.0)
@@ -1387,7 +1389,7 @@ extension BaseAPSManager: PumpManagerStatusObserver {
                 }
                 }
 
 
                 batteryToStore.date = Date()
                 batteryToStore.date = Date()
-                batteryToStore.percent = Int16(percent)
+                batteryToStore.percent = Double(percent)
                 batteryToStore.voltage = nil
                 batteryToStore.voltage = nil
                 batteryToStore.status = percent > 10 ? "normal" : "low"
                 batteryToStore.status = percent > 10 ? "normal" : "low"
                 batteryToStore.display = status.pumpBatteryChargeRemaining != nil
                 batteryToStore.display = status.pumpBatteryChargeRemaining != nil

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

@@ -132,7 +132,7 @@ final class BaseDeviceDataManager: DeviceDataManager, Injectable {
                             let saveBatteryToCoreData = OpenAPS_Battery(context: self.privateContext)
                             let saveBatteryToCoreData = OpenAPS_Battery(context: self.privateContext)
                             saveBatteryToCoreData.id = UUID()
                             saveBatteryToCoreData.id = UUID()
                             saveBatteryToCoreData.date = Date()
                             saveBatteryToCoreData.date = Date()
-                            saveBatteryToCoreData.percent = Int16(batteryPercent)
+                            saveBatteryToCoreData.percent = Double(batteryPercent)
                             saveBatteryToCoreData.voltage = nil
                             saveBatteryToCoreData.voltage = nil
                             saveBatteryToCoreData.status = batteryPercent >= 10 ? BatteryState.normal.rawValue : BatteryState
                             saveBatteryToCoreData.status = batteryPercent >= 10 ? BatteryState.normal.rawValue : BatteryState
                                 .low.rawValue
                                 .low.rawValue

+ 2 - 1
FreeAPS/Sources/APS/FetchGlucoseManager.swift

@@ -213,7 +213,8 @@ final class BaseFetchGlucoseManager: FetchGlucoseManager, Injectable {
                     unfiltered: Decimal(result.glucose),
                     unfiltered: Decimal(result.glucose),
                     filtered: Decimal(result.glucose),
                     filtered: Decimal(result.glucose),
                     noise: nil,
                     noise: nil,
-                    glucose: Int(result.glucose)
+                    glucose: Int(result.glucose),
+                    type: "sgv"
                 )
                 )
             }
             }
         }
         }

+ 2 - 1
FreeAPS/Sources/APS/Storage/GlucoseStorage.swift

@@ -299,7 +299,8 @@ final class BaseGlucoseStorage: GlucoseStorage, Injectable {
                     unfiltered: Decimal(result.glucose),
                     unfiltered: Decimal(result.glucose),
                     filtered: Decimal(result.glucose),
                     filtered: Decimal(result.glucose),
                     noise: nil,
                     noise: nil,
-                    glucose: Int(result.glucose)
+                    glucose: Int(result.glucose),
+                    type: "sgv"
                 )
                 )
             }
             }
         }
         }

+ 1 - 0
FreeAPS/Sources/Application/FreeAPSApp.swift

@@ -49,6 +49,7 @@ import Swinject
         _ = resolver.resolve(CalendarManager.self)!
         _ = resolver.resolve(CalendarManager.self)!
         _ = resolver.resolve(UserNotificationsManager.self)!
         _ = resolver.resolve(UserNotificationsManager.self)!
         _ = resolver.resolve(WatchManager.self)!
         _ = resolver.resolve(WatchManager.self)!
+        _ = resolver.resolve(ContactImageManager.self)!
         _ = resolver.resolve(HealthKitManager.self)!
         _ = resolver.resolve(HealthKitManager.self)!
         _ = resolver.resolve(BluetoothStateManager.self)!
         _ = resolver.resolve(BluetoothStateManager.self)!
         _ = resolver.resolve(PluginManager.self)!
         _ = resolver.resolve(PluginManager.self)!

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

@@ -136,7 +136,7 @@ struct DecimalPickerSettings {
     var hours = PickerSetting(value: 6, step: 0.5, min: 2, max: 24, type: PickerSetting.PickerSettingType.hour)
     var hours = PickerSetting(value: 6, step: 0.5, min: 2, max: 24, type: PickerSetting.PickerSettingType.hour)
     var dia = PickerSetting(value: 10, step: 0.5, min: 5, max: 10, type: PickerSetting.PickerSettingType.hour)
     var dia = PickerSetting(value: 10, step: 0.5, min: 5, max: 10, type: PickerSetting.PickerSettingType.hour)
     var maxBolus = PickerSetting(value: 10, step: 0.5, min: 1, max: 30, type: PickerSetting.PickerSettingType.insulinUnit)
     var maxBolus = PickerSetting(value: 10, step: 0.5, min: 1, max: 30, type: PickerSetting.PickerSettingType.insulinUnit)
-    var maxBasal = PickerSetting(value: 10, step: 0.5, min: 1, max: 30, type: PickerSetting.PickerSettingType.insulinUnit)
+    var maxBasal = PickerSetting(value: 10, step: 0.5, min: 0.5, max: 30, type: PickerSetting.PickerSettingType.insulinUnit)
 }
 }
 
 
 struct PickerSetting {
 struct PickerSetting {

+ 1 - 1
FreeAPS/Sources/Modules/Adjustments/View/Overrides/AddOverrideForm.swift

@@ -74,7 +74,7 @@ struct AddOverrideForm: View {
             Section(footer: state.percentageDescription(state.overridePercentage)) {
             Section(footer: state.percentageDescription(state.overridePercentage)) {
                 // Percentage Picker
                 // Percentage Picker
                 HStack {
                 HStack {
-                    Text("Change Basal Rate by")
+                    Text("Basal Rate Adjustment")
                     Spacer()
                     Spacer()
                     Text("\(state.overridePercentage.formatted(.number)) %")
                     Text("\(state.overridePercentage.formatted(.number)) %")
                         .foregroundColor(!displayPickerPercentage ? .primary : .accentColor)
                         .foregroundColor(!displayPickerPercentage ? .primary : .accentColor)

+ 1 - 1
FreeAPS/Sources/Modules/Adjustments/View/Overrides/EditOverrideForm.swift

@@ -140,7 +140,7 @@ struct EditOverrideForm: View {
             // Percentage Picker
             // Percentage Picker
             Section(footer: state.percentageDescription(percentage)) {
             Section(footer: state.percentageDescription(percentage)) {
                 HStack {
                 HStack {
-                    Text("Change Basal Rate by")
+                    Text("Basal Rate Adjustment")
                     Spacer()
                     Spacer()
                     Text("\(percentage.formatted(.number)) %")
                     Text("\(percentage.formatted(.number)) %")
                         .foregroundColor(!displayPickerPercentage ? .primary : .accentColor)
                         .foregroundColor(!displayPickerPercentage ? .primary : .accentColor)

+ 11 - 9
FreeAPS/Sources/Modules/BasalProfileEditor/View/BasalProfileEditorRootView.swift

@@ -84,23 +84,25 @@ extension BasalProfileEditor {
 
 
                 Group {
                 Group {
                     HStack {
                     HStack {
-                        Button {
+                        Button(action: {
                             let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
                             let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
                             impactHeavy.impactOccurred()
                             impactHeavy.impactOccurred()
                             state.save()
                             state.save()
-                        } label: {
+                        }, label: {
                             HStack {
                             HStack {
                                 if state.syncInProgress {
                                 if state.syncInProgress {
                                     ProgressView().padding(.trailing, 10)
                                     ProgressView().padding(.trailing, 10)
                                 }
                                 }
                                 Text(state.syncInProgress ? "Saving..." : "Save")
                                 Text(state.syncInProgress ? "Saving..." : "Save")
-                            }.padding(10)
-                        }
-                        .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
-                        .disabled(shouldDisableButton)
-                        .background(shouldDisableButton ? Color(.systemGray4) : Color(.systemBlue))
-                        .tint(.white)
-                        .clipShape(RoundedRectangle(cornerRadius: 8))
+                            }
+                            .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
+                            .padding(10)
+                        })
+                            .frame(width: UIScreen.main.bounds.width * 0.9, height: 40, alignment: .center)
+                            .disabled(shouldDisableButton)
+                            .background(shouldDisableButton ? Color(.systemGray4) : Color(.systemBlue))
+                            .tint(.white)
+                            .clipShape(RoundedRectangle(cornerRadius: 8))
                     }
                     }
                 }.padding(5)
                 }.padding(5)
             }
             }

+ 1 - 1
FreeAPS/Sources/Modules/BolusCalculatorConfig/View/BolusCalculatorConfigRootView.swift

@@ -138,7 +138,7 @@ extension BolusCalculatorConfig {
                     verboseHint:
                     verboseHint:
                     VStack(alignment: .leading, spacing: 10) {
                     VStack(alignment: .leading, spacing: 10) {
                         Text("Default: OFF").bold()
                         Text("Default: OFF").bold()
-                        Text("Default Percent: 200%").bold()
+                        Text("Default Percent: 100%").bold()
                         Text("Do not enable this feature until you have optimized your CR (carb ratio) setting.").bold()
                         Text("Do not enable this feature until you have optimized your CR (carb ratio) setting.").bold()
                         Text(
                         Text(
                             "Enabling this setting adds a \"Super Bolus\" option to the bolus calculator. Once this feature is enabled, a percentage setting will appear for you to select."
                             "Enabling this setting adds a \"Super Bolus\" option to the bolus calculator. Once this feature is enabled, a percentage setting will appear for you to select."

+ 3 - 1
FreeAPS/Sources/Modules/CarbRatioEditor/View/CarbRatioEditorRootView.swift

@@ -53,7 +53,9 @@ extension CarbRatioEditor {
                                         ProgressView().padding(.trailing, 10)
                                         ProgressView().padding(.trailing, 10)
                                     }
                                     }
                                     Text(state.shouldDisplaySaving ? "Saving..." : "Save")
                                     Text(state.shouldDisplaySaving ? "Saving..." : "Save")
-                                }.padding(10)
+                                }
+                                .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
+                                .padding(10)
                             }
                             }
                         }
                         }
                         .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
                         .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)

+ 1 - 4
FreeAPS/Sources/Modules/Home/HomeStateModel+Setup/GlucoseTargetSetup.swift

@@ -77,10 +77,7 @@ extension Home.StateModel {
                 )
                 )
             )
             )
         }
         }
-
-        // TODO: - remove this after bug is fixed
-        debugPrint("\(DebuggingIdentifiers.inProgress) printing target profiles: \(targetProfiles)")
-
+      
         return targetProfiles
         return targetProfiles
     }
     }
 }
 }

+ 1 - 0
FreeAPS/Sources/Modules/Home/HomeStateModel.swift

@@ -580,6 +580,7 @@ extension Home.StateModel:
         highGlucose = settingsManager.settings.high
         highGlucose = settingsManager.settings.high
         Task {
         Task {
             await getCurrentGlucoseTarget()
             await getCurrentGlucoseTarget()
+            await setupGlucoseTargets()
         }
         }
         hbA1cDisplayUnit = settingsManager.settings.hbA1cDisplayUnit
         hbA1cDisplayUnit = settingsManager.settings.hbA1cDisplayUnit
         glucoseColorScheme = settingsManager.settings.glucoseColorScheme
         glucoseColorScheme = settingsManager.settings.glucoseColorScheme

+ 1 - 1
FreeAPS/Sources/Modules/Home/View/Chart/ChartElements/CarbView.swift

@@ -50,7 +50,7 @@ struct CarbView: ChartContent {
         ForEach(fpuData, id: \.id) { fpu in
         ForEach(fpuData, id: \.id) { fpu in
             let fpuAmount = fpu.carbs
             let fpuAmount = fpu.carbs
             let size = (MainChartHelper.Config.fpuSize + CGFloat(fpuAmount) * MainChartHelper.Config.carbsScale) * 1.8
             let size = (MainChartHelper.Config.fpuSize + CGFloat(fpuAmount) * MainChartHelper.Config.carbsScale) * 1.8
-            let yPosition = minValue
+            let yPosition = minValue // value is parsed to mmol/L when passed into struct based on user settings
 
 
             PointMark(
             PointMark(
                 x: .value("Time", fpu.date ?? Date(), unit: .second),
                 x: .value("Time", fpu.date ?? Date(), unit: .second),

+ 2 - 1
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -157,7 +157,8 @@ extension MainChartView {
                     units: state.units,
                     units: state.units,
                     carbData: state.carbsFromPersistence,
                     carbData: state.carbsFromPersistence,
                     fpuData: state.fpusFromPersistence,
                     fpuData: state.fpusFromPersistence,
-                    minValue: state.minYAxisValue
+                    minValue: units == .mgdL ? state.minYAxisValue : state.minYAxisValue
+                        .asMmolL
                 )
                 )
 
 
                 ForecastView(
                 ForecastView(

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

@@ -91,7 +91,7 @@ struct PumpView: View {
                         Image(systemName: "battery.100")
                         Image(systemName: "battery.100")
                             .font(.callout)
                             .font(.callout)
                             .foregroundStyle(batteryColor)
                             .foregroundStyle(batteryColor)
-                        Text("\(Int(battery.first?.percent ?? 100)) %")
+                        Text("\(Formatter.integerFormatter.string(for: battery.first?.percent ?? 100) ?? "100") %")
                             .font(.callout).fontWeight(.bold).fontDesign(.rounded)
                             .font(.callout).fontWeight(.bold).fontDesign(.rounded)
                     }
                     }
                 }
                 }

+ 8 - 1
FreeAPS/Sources/Modules/ISFEditor/View/ISFEditorRootView.swift

@@ -46,7 +46,14 @@ extension ISFEditor {
                                     state.shouldDisplaySaving = false
                                     state.shouldDisplaySaving = false
                                 }
                                 }
                             } label: {
                             } label: {
-                                Text(state.shouldDisplaySaving ? "Saving..." : "Save").padding(10)
+                                HStack {
+                                    if state.shouldDisplaySaving {
+                                        ProgressView().padding(.trailing, 10)
+                                    }
+                                    Text(state.shouldDisplaySaving ? "Saving..." : "Save")
+                                }
+                                .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
+                                .padding(10)
                             }
                             }
                         }
                         }
                         .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
                         .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)

+ 33 - 38
FreeAPS/Sources/Modules/PumpConfig/View/PumpConfigRootView.swift

@@ -57,25 +57,6 @@ extension PumpConfig {
                                         Spacer()
                                         Spacer()
                                         Button(
                                         Button(
                                             action: {
                                             action: {
-                                                hintLabel = "Pump Pairing to Trio"
-                                                selectedVerboseHint =
-                                                    AnyView(
-                                                        VStack(alignment: .leading, spacing: 10) {
-                                                            Text(
-                                                                "Current Pump Models Supported:"
-                                                            )
-                                                            VStack(alignment: .leading) {
-                                                                Text("• Medtronic")
-                                                                Text("• Omnipod Eros")
-                                                                Text("• Omnipod Dash")
-                                                                Text("• Dana (RS/-i)")
-                                                                Text("• Pump Simulator")
-                                                            }
-                                                            Text(
-                                                                "Note: If using a pump simulator, you will not have continuous readings from the CGM in Trio. Using a pump simulator is only advisable for becoming familiar with the app user interface. It will not give you insight on how the algorithm will respond."
-                                                            )
-                                                        }
-                                                    )
                                                 shouldDisplayHint.toggle()
                                                 shouldDisplayHint.toggle()
                                             },
                                             },
                                             label: {
                                             label: {
@@ -97,25 +78,7 @@ extension PumpConfig {
                 .navigationTitle("Insulin Pump")
                 .navigationTitle("Insulin Pump")
                 .navigationBarTitleDisplayMode(.automatic)
                 .navigationBarTitleDisplayMode(.automatic)
                 .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
                 .navigationBarItems(leading: displayClose ? Button("Close", action: state.hideModal) : nil)
-                .sheet(isPresented: $shouldDisplayHint) {
-                    SettingInputHintView(
-                        hintDetent: $hintDetent,
-                        shouldDisplayHint: $shouldDisplayHint,
-                        hintLabel: hintLabel ?? "",
-                        hintText: selectedVerboseHint ?? AnyView(EmptyView()),
-                        sheetTitle: "Help"
-                    )
-                }
-                .confirmationDialog("Pump Model", isPresented: $showPumpSelection) {
-                    Button("Medtronic") { state.addPump(.minimed) }
-                    Button("Omnipod Eros") { state.addPump(.omnipod) }
-                    Button("Omnipod Dash") { state.addPump(.omnipodBLE) }
-                    Button("Dana(RS/-i)") { state.addPump(.dana) }
-                    Button("Pump Simulator") { state.addPump(.simulator) }
-                } message: { Text("Select Pump Model") }
-            }
-            .sheet(isPresented: $state.setupPump) {
-                NavigationView {
+                .sheet(isPresented: $state.setupPump) {
                     if let pumpManager = state.provider.apsManager.pumpManager {
                     if let pumpManager = state.provider.apsManager.pumpManager {
                         PumpSettingsView(
                         PumpSettingsView(
                             pumpManager: pumpManager,
                             pumpManager: pumpManager,
@@ -133,6 +96,38 @@ extension PumpConfig {
                         )
                         )
                     }
                     }
                 }
                 }
+                .sheet(isPresented: $shouldDisplayHint) {
+                    SettingInputHintView(
+                        hintDetent: $hintDetent,
+                        shouldDisplayHint: $shouldDisplayHint,
+                        hintLabel: "Pump Pairing to Trio",
+                        hintText: AnyView(
+                            VStack(alignment: .leading, spacing: 10) {
+                                Text(
+                                    "Current Pump Models Supported:"
+                                )
+                                VStack(alignment: .leading) {
+                                    Text("• Medtronic")
+                                    Text("• Omnipod Eros")
+                                    Text("• Omnipod Dash")
+                                    Text("• Dana (RS/-i)")
+                                    Text("• Pump Simulator")
+                                }
+                                Text(
+                                    "Note: If using a pump simulator, you will not have continuous readings from the CGM in Trio. Using a pump simulator is only advisable for becoming familiar with the app user interface. It will not give you insight on how the algorithm will respond."
+                                )
+                            }
+                        ),
+                        sheetTitle: "Help"
+                    )
+                }
+                .confirmationDialog("Pump Model", isPresented: $showPumpSelection) {
+                    Button("Medtronic") { state.addPump(.minimed) }
+                    Button("Omnipod Eros") { state.addPump(.omnipod) }
+                    Button("Omnipod Dash") { state.addPump(.omnipodBLE) }
+                    Button("Dana(RS/-i)") { state.addPump(.dana) }
+                    Button("Pump Simulator") { state.addPump(.simulator) }
+                } message: { Text("Select Pump Model") }
             }
             }
         }
         }
     }
     }

+ 1 - 1
FreeAPS/Sources/Modules/SMBSettings/View/SMBSettingsRootView.swift

@@ -306,7 +306,7 @@ extension SMBSettings {
                         }
                         }
                         VStack(alignment: .leading, spacing: 10) {
                         VStack(alignment: .leading, spacing: 10) {
                             Text(
                             Text(
-                                "Warning: Increasing this value above 90 minutes may impact Trio's ability to effectively zero temp and prevent lows."
+                                "Warning: Increasing this value above 60 minutes may impact Trio's ability to effectively zero temp and prevent lows."
                             ).bold()
                             ).bold()
                             Text("Note: UAM SMBs must be enabled to use this limit.")
                             Text("Note: UAM SMBs must be enabled to use this limit.")
                         }
                         }

+ 2 - 7
FreeAPS/Sources/Modules/Stat/View/StatsView.swift

@@ -128,13 +128,8 @@ struct StatsView: View {
     var hba1c: some View {
     var hba1c: some View {
         HStack(spacing: 50) {
         HStack(spacing: 50) {
             let useUnit: GlucoseUnits = {
             let useUnit: GlucoseUnits = {
-                if units == .mmolL && hbA1cDisplayUnit == .mmolMol {
-                    return .mgdL
-                } else if (units == .mgdL && hbA1cDisplayUnit == .mmolMol) || units == .mmolL {
-                    return .mmolL
-                } else {
-                    return .mgdL
-                }
+                if hbA1cDisplayUnit == .mmolMol { return .mmolL }
+                else { return .mgdL }
             }()
             }()
 
 
             let hba1cs = glucoseStats()
             let hba1cs = glucoseStats()

+ 22 - 22
FreeAPS/Sources/Modules/TargetsEditor/View/TargetsEditorRootView.swift

@@ -31,30 +31,30 @@ extension TargetsEditor {
 
 
                 Group {
                 Group {
                     HStack {
                     HStack {
-                        HStack {
-                            Button {
-                                let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
-                                impactHeavy.impactOccurred()
-                                state.save()
-
-                                // deactivate saving display after 1.25 seconds
-                                DispatchQueue.main.asyncAfter(deadline: .now() + 1.25) {
-                                    state.shouldDisplaySaving = false
+                        Button(action: {
+                            let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
+                            impactHeavy.impactOccurred()
+                            state.save()
+
+                            // deactivate saving display after 1.25 seconds
+                            DispatchQueue.main.asyncAfter(deadline: .now() + 1.25) {
+                                state.shouldDisplaySaving = false
+                            }
+                        }, label: {
+                            HStack {
+                                if state.shouldDisplaySaving {
+                                    ProgressView().padding(.trailing, 10)
                                 }
                                 }
-                            } label: {
-                                HStack {
-                                    if state.shouldDisplaySaving {
-                                        ProgressView().padding(.trailing, 10)
-                                    }
-                                    Text(state.shouldDisplaySaving ? "Saving..." : "Save")
-                                }.padding(10)
+                                Text(state.shouldDisplaySaving ? "Saving..." : "Save")
                             }
                             }
-                        }
-                        .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
-                        .disabled(shouldDisableButton)
-                        .background(shouldDisableButton ? Color(.systemGray4) : Color(.systemBlue))
-                        .tint(.white)
-                        .clipShape(RoundedRectangle(cornerRadius: 8))
+                            .frame(width: UIScreen.main.bounds.width * 0.9, alignment: .center)
+                            .padding(10)
+                        })
+                            .frame(width: UIScreen.main.bounds.width * 0.9, height: 40, alignment: .center)
+                            .disabled(shouldDisableButton)
+                            .background(shouldDisableButton ? Color(.systemGray4) : Color(.systemBlue))
+                            .tint(.white)
+                            .clipShape(RoundedRectangle(cornerRadius: 8))
                     }
                     }
                 }.padding(5)
                 }.padding(5)
             }
             }

+ 12 - 10
FreeAPS/Sources/Modules/Treatments/View/TreatmentsRootView.swift

@@ -316,15 +316,17 @@ extension Treatments {
                         Text("Close")
                         Text("Close")
                     }
                     }
                 }
                 }
-                ToolbarItem(placement: .topBarTrailing) {
-                    Button(action: {
-                        showPresetSheet = true
-                    }, label: {
-                        HStack {
-                            Text("Presets")
-                            Image(systemName: "plus")
-                        }
-                    })
+                if state.displayPresets {
+                    ToolbarItem(placement: .topBarTrailing) {
+                        Button(action: {
+                            showPresetSheet = true
+                        }, label: {
+                            HStack {
+                                Text("Presets")
+                                Image(systemName: "plus")
+                            }
+                        })
+                    }
                 }
                 }
             })
             })
             .onAppear {
             .onAppear {
@@ -396,7 +398,7 @@ extension Treatments {
 
 
         private var taskButtonLabel: some View {
         private var taskButtonLabel: some View {
             if pumpBolusLimitExceeded {
             if pumpBolusLimitExceeded {
-                return Text("Max Bolus of \(state.maxBolus.description) U E== 0xceeded")
+                return Text("Max Bolus of \(state.maxBolus.description) U Exceeded")
             } else if externalBolusLimitExceeded {
             } else if externalBolusLimitExceeded {
                 return Text("Max External Bolus of \(state.maxExternal.description) U Exceeded")
                 return Text("Max External Bolus of \(state.maxExternal.description) U Exceeded")
             } else if carbLimitExceeded {
             } else if carbLimitExceeded {

+ 14 - 16
FreeAPS/Sources/Modules/WatchConfig/View/WatchConfigGarminView.swift

@@ -19,7 +19,7 @@ struct WatchConfigGarminView: View {
     }
     }
 
 
     var body: some View {
     var body: some View {
-        List {
+        Form {
             Section(
             Section(
                 header: Text("Garmin Configuration"),
                 header: Text("Garmin Configuration"),
                 content:
                 content:
@@ -43,13 +43,6 @@ struct WatchConfigGarminView: View {
                             Spacer()
                             Spacer()
                             Button(
                             Button(
                                 action: {
                                 action: {
-                                    hintLabel = "Add Device"
-                                    selectedVerboseHint =
-                                        AnyView(
-                                            Text(
-                                                "Add Garmin Device to Trio. Please look at the docs to see which devices are supported."
-                                            )
-                                        )
                                     shouldDisplayHint.toggle()
                                     shouldDisplayHint.toggle()
                                 },
                                 },
                                 label: {
                                 label: {
@@ -64,14 +57,17 @@ struct WatchConfigGarminView: View {
             ).listRowBackground(Color.chart)
             ).listRowBackground(Color.chart)
 
 
             if !state.devices.isEmpty {
             if !state.devices.isEmpty {
-                Section(header: Text("Garmin Watch")) {
-                    List {
-                        ForEach(state.devices, id: \.uuid) { device in
-                            Text(device.friendlyName)
+                Section(
+                    header: Text("Garmin Watch"),
+                    content: {
+                        List {
+                            ForEach(state.devices, id: \.uuid) { device in
+                                Text(device.friendlyName)
+                            }
+                            .onDelete(perform: onDelete)
                         }
                         }
-                        .onDelete(perform: onDelete)
                     }
                     }
-                }.listRowBackground(Color.chart)
+                ).listRowBackground(Color.chart)
             }
             }
         }
         }
         .listSectionSpacing(sectionSpacing)
         .listSectionSpacing(sectionSpacing)
@@ -79,8 +75,10 @@ struct WatchConfigGarminView: View {
             SettingInputHintView(
             SettingInputHintView(
                 hintDetent: $hintDetent,
                 hintDetent: $hintDetent,
                 shouldDisplayHint: $shouldDisplayHint,
                 shouldDisplayHint: $shouldDisplayHint,
-                hintLabel: hintLabel ?? "",
-                hintText: selectedVerboseHint ?? AnyView(EmptyView()),
+                hintLabel: "Add Device",
+                hintText: Text(
+                    "Add Garmin Device to Trio. Please look at the docs to see which devices are supported."
+                ),
                 sheetTitle: "Help"
                 sheetTitle: "Help"
             )
             )
         }
         }

+ 1 - 1
Model/Classes+Properties/OpenAPS_Battery+CoreDataProperties.swift

@@ -9,7 +9,7 @@ public extension OpenAPS_Battery {
     @NSManaged var date: Date?
     @NSManaged var date: Date?
     @NSManaged var display: Bool
     @NSManaged var display: Bool
     @NSManaged var id: UUID?
     @NSManaged var id: UUID?
-    @NSManaged var percent: Int16
+    @NSManaged var percent: Double
     @NSManaged var status: String?
     @NSManaged var status: String?
     @NSManaged var voltage: NSDecimalNumber?
     @NSManaged var voltage: NSDecimalNumber?
 }
 }

+ 1 - 1
Model/TrioCoreDataPersistentContainer.xcdatamodeld/TrioCoreDataPersistentContainer.xcdatamodel/contents

@@ -96,7 +96,7 @@
         <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
         <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
         <attribute name="display" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
         <attribute name="display" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
         <attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
         <attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
-        <attribute name="percent" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
+        <attribute name="percent" optional="YES" attributeType="Double" defaultValueString="0" usesScalarValueType="YES"/>
         <attribute name="status" optional="YES" attributeType="String"/>
         <attribute name="status" optional="YES" attributeType="String"/>
         <attribute name="voltage" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
         <attribute name="voltage" optional="YES" attributeType="Decimal" defaultValueString="0.0"/>
         <fetchIndex name="byDate">
         <fetchIndex name="byDate">