From edacd2c6e08c8268cf4a584b967330db2cd2156d Mon Sep 17 00:00:00 2001 From: "Jon B.M" Date: Tue, 18 Feb 2025 20:28:40 +0100 Subject: [PATCH] Option to only display SAGE --- .../Resources/json/defaults/freeaps/freeaps_settings.json | 3 ++- FreeAPS/Sources/Models/FreeAPSSettings.swift | 5 +++++ FreeAPS/Sources/Modules/Home/HomeStateModel.swift | 3 +++ .../Modules/Home/View/Header/CurrentGlucoseView.swift | 8 +++++--- FreeAPS/Sources/Modules/Home/View/HomeRootView.swift | 2 +- .../Sources/Modules/StatConfig/StatConfigStateModel.swift | 2 ++ .../Modules/StatConfig/View/StatConfigRootView.swift | 4 ++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json b/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json index ec3c1333f1..289890a11d 100644 --- a/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json +++ b/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json @@ -95,5 +95,6 @@ "ketoProtectBasalAbsolut": 0, "extendHomeView": true, "extended_overrides": false, - "displayExpiration": false + "displayExpiration": false, + "anubis": false } diff --git a/FreeAPS/Sources/Models/FreeAPSSettings.swift b/FreeAPS/Sources/Models/FreeAPSSettings.swift index e039b01182..7668f26823 100644 --- a/FreeAPS/Sources/Models/FreeAPSSettings.swift +++ b/FreeAPS/Sources/Models/FreeAPSSettings.swift @@ -76,6 +76,7 @@ struct FreeAPSSettings: JSON, Equatable { var extendHomeView = true var displayExpiration = false var sensorDays: Double = 10 + var anubis: Bool = false // Auto ISF var autoisf: Bool = false var smbDeliveryRatioBGrange: Decimal = 0 @@ -196,6 +197,10 @@ extension FreeAPSSettings: Decodable { settings.useFPUconversion = useFPUconversion } + if let anubis = try? container.decode(Bool.self, forKey: .anubis) { + settings.anubis = anubis + } + if let individualAdjustmentFactor = try? container.decode(Decimal.self, forKey: .individualAdjustmentFactor) { settings.individualAdjustmentFactor = individualAdjustmentFactor } diff --git a/FreeAPS/Sources/Modules/Home/HomeStateModel.swift b/FreeAPS/Sources/Modules/Home/HomeStateModel.swift index 818a1bbc12..98d2fbdfe9 100644 --- a/FreeAPS/Sources/Modules/Home/HomeStateModel.swift +++ b/FreeAPS/Sources/Modules/Home/HomeStateModel.swift @@ -78,6 +78,7 @@ extension Home { @Published var displayExpiration = false @Published var cgm: CGMType = .nightscout @Published var sensorDays: Double = 10 + @Published var anubis: Bool = false // Chart data var data = ChartModel( @@ -166,6 +167,7 @@ extension Home { displayExpiration = settingsManager.settings.displayExpiration cgm = settingsManager.settings.cgm sensorDays = settingsManager.settings.sensorDays + anubis = settingsManager.settings.anubis broadcaster.register(GlucoseObserver.self, observer: self) broadcaster.register(SuggestionObserver.self, observer: self) @@ -653,6 +655,7 @@ extension Home.StateModel: displayExpiration = settingsManager.settings.displayExpiration cgm = settingsManager.settings.cgm sensorDays = settingsManager.settings.sensorDays + anubis = settingsManager.settings.anubis setupGlucose() setupOverrideHistory() setupData() diff --git a/FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift b/FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift index 7af61a2762..e332ef4e50 100644 --- a/FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift +++ b/FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift @@ -13,6 +13,7 @@ struct CurrentGlucoseView: View { @Binding var displayExpiration: Bool @Binding var cgm: CGMType @Binding var sensordays: Double + @Binding var anubis: Bool @Environment(\.colorScheme) var colorScheme @Environment(\.sizeCategory) private var fontSize @@ -96,7 +97,7 @@ struct CurrentGlucoseView: View { if let recent = recentGlucose { if displayDelta, !scrolling, let deltaInt = delta, !(units == .mmolL && abs(deltaInt) <= 1) { deltaView(deltaInt) } - if displayExpiration { + if displayExpiration || anubis { sageView } VStack(spacing: 15) { @@ -142,9 +143,10 @@ struct CurrentGlucoseView: View { ZStack { if let date = recentGlucose?.sessionStartDate { let expiration = (cgm == .xdrip || cgm == .glucoseDirect) ? sensordays * 8.64E4 : cgm.expiration - let remainingTime: TimeInterval = expiration - (-1 * date.timeIntervalSinceNow) + let remainingTime: TimeInterval = anubis ? (-1 * date.timeIntervalSinceNow) : expiration - + (-1 * date.timeIntervalSinceNow) - Sage(amount: remainingTime, expiration: expiration) + Sage(amount: remainingTime, expiration: anubis ? remainingTime : expiration) .frame(width: 59, height: 26) .overlay { HStack { diff --git a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift index 3fdf417e2b..f98ecc221f 100644 --- a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift +++ b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift @@ -109,7 +109,7 @@ extension Home { alwaysUseColors: $state.alwaysUseColors, displayDelta: $state.displayDelta, scrolling: $displayGlucose, - displayExpiration: $state.displayExpiration, cgm: $state.cgm, sensordays: $state.sensorDays + displayExpiration: $state.displayExpiration, cgm: $state.cgm, sensordays: $state.sensorDays, anubis: $state.anubis ) .onTapGesture { if state.alarm == nil { diff --git a/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift b/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift index fd0796e089..206a63de56 100644 --- a/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift +++ b/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift @@ -21,6 +21,7 @@ extension StatConfig { @Published var hideInsulinBadge: Bool = false @Published var extendHomeView: Bool = true @Published var displayExpiration: Bool = false + @Published var anubis: Bool = false var units: GlucoseUnits = .mmolL @@ -43,6 +44,7 @@ extension StatConfig { subscribeSetting(\.hideInsulinBadge, on: $hideInsulinBadge) { hideInsulinBadge = $0 } subscribeSetting(\.extendHomeView, on: $extendHomeView) { extendHomeView = $0 } subscribeSetting(\.displayExpiration, on: $displayExpiration) { displayExpiration = $0 } + subscribeSetting(\.anubis, on: $anubis) { anubis = $0 } subscribeSetting(\.low, on: $low, initial: { let value = max(min($0, 90), 40) diff --git a/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift b/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift index fbbfc84c95..2cc3d71459 100644 --- a/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift +++ b/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift @@ -67,6 +67,10 @@ extension StatConfig { Toggle("Hide Concentration Badge", isOn: $state.hideInsulinBadge) } header: { Text("Header settings") } + Section { + Toggle("Display Sensor Age, but not Time Remaining", isOn: $state.anubis) + } header: { Text("Anubis") } + Section { HStack { Text("Low")