Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement alternative Bolus calculator #286

Merged
merged 26 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
df7e318
just a git test
polscm32 Oct 24, 2023
1910070
revert changes in config
polscm32 Oct 24, 2023
f15a915
add my raw bolus calc code
polscm32 Oct 17, 2023
4e85857
test if pushing works
polscm32 Oct 17, 2023
70ac178
refactoring code and (re)create popover
polscm32 Oct 18, 2023
2074be7
recreate popup, change its UI so that is is better readable
polscm32 Oct 19, 2023
e590016
implement rounding functions and grep basal and display it in popup
polscm32 Oct 19, 2023
414dca8
reimplement default iAPS bolus calc and add toggle function in bolus …
polscm32 Oct 19, 2023
715b6eb
add options for fatty meals in bolus calc config settings and apply a…
polscm32 Oct 20, 2023
efb0e3a
add (missing) insulin calculation in popup view, some minor changes...
polscm32 Oct 20, 2023
197f655
organizing code and retrieving carb ratios
polscm32 Oct 22, 2023
ed15f84
add mmol/l conversion
polscm32 Oct 22, 2023
de2a9b6
fix mmol/l conversion for blood glucose in first section of the bolus…
polscm32 Oct 22, 2023
50302cf
fix carb warning
polscm32 Oct 22, 2023
8d6714a
fix problem with DecimalTextFields which throw error UIViewAlertForUn…
polscm32 Oct 22, 2023
9a77300
Merge remote-tracking branch 'upstream/dev' into bolus_calc_tests to
polscm32 Oct 26, 2023
f1eae10
pull in latest dev and solve merge conflicts
polscm32 Oct 27, 2023
2237333
change navigationBarTitleDisplayMode to .inline like in #269 and make…
polscm32 Oct 27, 2023
9597ef6
delete unused pizza image (intended for fatty meal toggle...)
polscm32 Oct 27, 2023
91057cf
remove font modifier so that buttons across the views look more consi…
polscm32 Oct 27, 2023
f69256d
pull in latest dev
polscm32 Oct 28, 2023
008902b
removes plus button in bolus calculator because external insulin will…
polscm32 Oct 28, 2023
d25b25b
removes alert that belongs to the plus button which adds non-pump ins…
polscm32 Oct 28, 2023
687b30a
pull in latest dev and solve merge conflicts
polscm32 Oct 29, 2023
fe55e3b
remove carb entry field in bolus calculator for now and code that bel…
polscm32 Oct 29, 2023
246864c
update enact bolus button description when amount exceeds maxBolus an…
polscm32 Oct 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@
BA00D96F7B2FF169A06FB530 /* CGMStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C018D1680307A31C9ED7120 /* CGMStateModel.swift */; };
BA90041DC8991147E5C8C3AA /* CalibrationsRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500371C09F54F89A97D65FDB /* CalibrationsRootView.swift */; };
BD2B464E0745FBE7B79913F4 /* NightscoutConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BF768BD6264FF7D71D66767 /* NightscoutConfigProvider.swift */; };
BD2FF1A02AE29D43005D1C5D /* CheckboxToggleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2FF19F2AE29D43005D1C5D /* CheckboxToggleStyle.swift */; };
BD7DA9A52AE06DFC00601B20 /* BolusCalculatorConfigDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7DA9A42AE06DFC00601B20 /* BolusCalculatorConfigDataFlow.swift */; };
BD7DA9A72AE06E2B00601B20 /* BolusCalculatorConfigProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7DA9A62AE06E2B00601B20 /* BolusCalculatorConfigProvider.swift */; };
BD7DA9A92AE06E9200601B20 /* BolusCalculatorStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7DA9A82AE06E9200601B20 /* BolusCalculatorStateModel.swift */; };
BD7DA9AC2AE06EB900601B20 /* BolusCalculatorConfigRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7DA9AB2AE06EB900601B20 /* BolusCalculatorConfigRootView.swift */; };
BDFD165A2AE40438007F0DDA /* AlternativeBolusCalcRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDFD16592AE40438007F0DDA /* AlternativeBolusCalcRootView.swift */; };
BDFD165C2AE40688007F0DDA /* DefaultBolusCalcRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDFD165B2AE40688007F0DDA /* DefaultBolusCalcRootView.swift */; };
BF1667ADE69E4B5B111CECAE /* ManualTempBasalProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 680C4420C9A345D46D90D06C /* ManualTempBasalProvider.swift */; };
C967DACD3B1E638F8B43BE06 /* ManualTempBasalStateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFCFE0781F9074C2917890E8 /* ManualTempBasalStateModel.swift */; };
CA370FC152BC98B3D1832968 /* BasalProfileEditorRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8BCB0C37DEB5EC377B9612 /* BasalProfileEditorRootView.swift */; };
Expand Down Expand Up @@ -819,6 +826,13 @@
B9CAAEFB2AE70836000F68BC /* branch.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = branch.txt; sourceTree = SOURCE_ROOT; };
BA49538D56989D8DA6FCF538 /* TargetsEditorDataFlow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = TargetsEditorDataFlow.swift; sourceTree = "<group>"; };
BC210C0F3CB6D3C86E5DED4E /* LibreConfigRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = LibreConfigRootView.swift; sourceTree = "<group>"; };
BD2FF19F2AE29D43005D1C5D /* CheckboxToggleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxToggleStyle.swift; sourceTree = "<group>"; };
BD7DA9A42AE06DFC00601B20 /* BolusCalculatorConfigDataFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BolusCalculatorConfigDataFlow.swift; sourceTree = "<group>"; };
BD7DA9A62AE06E2B00601B20 /* BolusCalculatorConfigProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BolusCalculatorConfigProvider.swift; sourceTree = "<group>"; };
BD7DA9A82AE06E9200601B20 /* BolusCalculatorStateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BolusCalculatorStateModel.swift; sourceTree = "<group>"; };
BD7DA9AB2AE06EB900601B20 /* BolusCalculatorConfigRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BolusCalculatorConfigRootView.swift; sourceTree = "<group>"; };
BDFD16592AE40438007F0DDA /* AlternativeBolusCalcRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlternativeBolusCalcRootView.swift; sourceTree = "<group>"; };
BDFD165B2AE40688007F0DDA /* DefaultBolusCalcRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultBolusCalcRootView.swift; sourceTree = "<group>"; };
BF8BCB0C37DEB5EC377B9612 /* BasalProfileEditorRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BasalProfileEditorRootView.swift; sourceTree = "<group>"; };
C19984D62EFC0035A9E9644D /* BolusProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BolusProvider.swift; sourceTree = "<group>"; };
C377490C77661D75E8C50649 /* ManualTempBasalRootView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ManualTempBasalRootView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1154,6 +1168,7 @@
3811DE0325C9D31700A708ED /* Modules */ = {
isa = PBXGroup;
children = (
BD7DA9A32AE06DBA00601B20 /* BolusCalculatorConfig */,
190EBCC229FF134900BA767D /* StatConfig */,
CE94597C29E9E1CD0047C9C6 /* WatchConfig */,
19F95FF129F10F9C00314DDC /* Stat */,
Expand Down Expand Up @@ -2039,6 +2054,35 @@
isa = PBXGroup;
children = (
10A0C32B0DAB52726EF9B6D9 /* BolusRootView.swift */,
BDFD165B2AE40688007F0DDA /* DefaultBolusCalcRootView.swift */,
BDFD16592AE40438007F0DDA /* AlternativeBolusCalcRootView.swift */,
);
path = View;
sourceTree = "<group>";
};
BD2FF19E2AE29D24005D1C5D /* Components */ = {
isa = PBXGroup;
children = (
BD2FF19F2AE29D43005D1C5D /* CheckboxToggleStyle.swift */,
);
path = Components;
sourceTree = "<group>";
};
BD7DA9A32AE06DBA00601B20 /* BolusCalculatorConfig */ = {
isa = PBXGroup;
children = (
BD7DA9A42AE06DFC00601B20 /* BolusCalculatorConfigDataFlow.swift */,
BD7DA9A62AE06E2B00601B20 /* BolusCalculatorConfigProvider.swift */,
BD7DA9A82AE06E9200601B20 /* BolusCalculatorStateModel.swift */,
BD7DA9AA2AE06E9600601B20 /* View */,
);
path = BolusCalculatorConfig;
sourceTree = "<group>";
};
BD7DA9AA2AE06E9600601B20 /* View */ = {
isa = PBXGroup;
children = (
BD7DA9AB2AE06EB900601B20 /* BolusCalculatorConfigRootView.swift */,
);
path = View;
sourceTree = "<group>";
Expand All @@ -2057,6 +2101,7 @@
C2C98283C436DB934D7E7994 /* Bolus */ = {
isa = PBXGroup;
children = (
BD2FF19E2AE29D24005D1C5D /* Components */,
C8D1A7CA8C10C4403D4BBFA7 /* BolusDataFlow.swift */,
C19984D62EFC0035A9E9644D /* BolusProvider.swift */,
223EC0494F55A91E3EA69EF4 /* BolusStateModel.swift */,
Expand Down Expand Up @@ -2632,6 +2677,7 @@
3811DE6125C9D4D500A708ED /* ViewModifiers.swift in Sources */,
3811DEAC25C9D88300A708ED /* NightscoutManager.swift in Sources */,
19A910302A24BF6300C8951B /* StatsView.swift in Sources */,
BD7DA9A92AE06E9200601B20 /* BolusCalculatorStateModel.swift in Sources */,
CEB434E528B8FF5D00B70274 /* UIColor.swift in Sources */,
190EBCCB29FF13CB00BA767D /* StatConfigRootView.swift in Sources */,
3811DEA925C9D88300A708ED /* AppearanceManager.swift in Sources */,
Expand Down Expand Up @@ -2663,6 +2709,7 @@
193F6CDD2A512C8F001240FD /* Loops.swift in Sources */,
38B4F3CB25E502E200E76A18 /* WeakObjectSet.swift in Sources */,
38E989DD25F5021400C0CED0 /* PumpStatus.swift in Sources */,
BDFD165A2AE40438007F0DDA /* AlternativeBolusCalcRootView.swift in Sources */,
38E98A2525F52C9300C0CED0 /* IssueReporter.swift in Sources */,
190EBCC429FF136900BA767D /* StatConfigDataFlow.swift in Sources */,
3811DEB025C9D88300A708ED /* BaseKeychain.swift in Sources */,
Expand All @@ -2688,6 +2735,7 @@
9825E5E923F0B8FA80C8C7C7 /* NightscoutConfigStateModel.swift in Sources */,
38A43598262E0E4900E80935 /* FetchAnnouncementsManager.swift in Sources */,
642F76A05A4FF530463A9FD0 /* NightscoutConfigRootView.swift in Sources */,
BD7DA9AC2AE06EB900601B20 /* BolusCalculatorConfigRootView.swift in Sources */,
AD3D2CD42CD01B9EB8F26522 /* PumpConfigDataFlow.swift in Sources */,
53F2382465BF74DB1A967C8B /* PumpConfigProvider.swift in Sources */,
5D16287A969E64D18CE40E44 /* PumpConfigStateModel.swift in Sources */,
Expand Down Expand Up @@ -2729,6 +2777,7 @@
DBA5254DBB2586C98F61220C /* ISFEditorProvider.swift in Sources */,
1BBB001DAD60F3B8CEA4B1C7 /* ISFEditorStateModel.swift in Sources */,
F816826028DB441800054060 /* BluetoothTransmitter.swift in Sources */,
BD7DA9A72AE06E2B00601B20 /* BolusCalculatorConfigProvider.swift in Sources */,
38192E0D261BAF980094D973 /* ConvenienceExtensions.swift in Sources */,
FEFA5C0F299F810B00765C17 /* Core_Data.xcdatamodeld in Sources */,
88AB39B23C9552BD6E0C9461 /* ISFEditorRootView.swift in Sources */,
Expand Down Expand Up @@ -2768,6 +2817,7 @@
CE82E02728E869DF00473A9C /* AlertEntry.swift in Sources */,
38E4451E274DB04600EC9A94 /* AppDelegate.swift in Sources */,
5BFA1C2208114643B77F8CEB /* AddTempTargetProvider.swift in Sources */,
BD2FF1A02AE29D43005D1C5D /* CheckboxToggleStyle.swift in Sources */,
E0D4F80527513ECF00BDF1FE /* HealthKitSample.swift in Sources */,
919DBD08F13BAFB180DF6F47 /* AddTempTargetStateModel.swift in Sources */,
8BC2F5A29AD1ED08AC0EE013 /* AddTempTargetRootView.swift in Sources */,
Expand All @@ -2780,6 +2830,7 @@
69A31254F2451C20361D172F /* BolusStateModel.swift in Sources */,
0CEA2EA070AB041AF3E3745B /* BolusRootView.swift in Sources */,
1967DFC029D053AC00759F30 /* IconSelection.swift in Sources */,
BDFD165C2AE40688007F0DDA /* DefaultBolusCalcRootView.swift in Sources */,
19D4E4EB29FC6A9F00351451 /* TIRforChart.swift in Sources */,
FEFFA7A22929FE49007B8193 /* UIDevice+Extensions.swift in Sources */,
F90692D3274B9A130037068D /* AppleHealthKitRootView.swift in Sources */,
Expand Down Expand Up @@ -2807,6 +2858,7 @@
F5CA3DB1F9DC8B05792BBFAA /* CGMDataFlow.swift in Sources */,
BA00D96F7B2FF169A06FB530 /* CGMStateModel.swift in Sources */,
61962FCAF8A2D222553AC5A3 /* LibreConfigDataFlow.swift in Sources */,
BD7DA9A52AE06DFC00601B20 /* BolusCalculatorConfigDataFlow.swift in Sources */,
6EADD581738D64431902AC0A /* LibreConfigProvider.swift in Sources */,
CE94598729E9E4110047C9C6 /* WatchConfigRootView.swift in Sources */,
903D18976088B09110BCBE29 /* LibreConfigStateModel.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"package": "SwiftCharts",
"repositoryURL": "https://github.com/ivanschuetz/SwiftCharts.git",
"repositoryURL": "https://github.com/ivanschuetz/SwiftCharts",
"state": {
"branch": "master",
"revision": "c354c1945bb35a1f01b665b22474f6db28cba4a2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
"oneDimensionalGraph" : false,
"rulerMarks" : false,
"maxCarbs": 1000,
"displayFatAndProteinOnWatch": false
"displayFatAndProteinOnWatch": false,
"overrideFactor": 0.8,
"useCalc": false,
"fattyMeals": false,
"fattyMealFactor": 0.7
}
20 changes: 20 additions & 0 deletions FreeAPS/Sources/Models/FreeAPSSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ struct FreeAPSSettings: JSON, Equatable {
var maxCarbs: Decimal = 1000
var displayFatAndProteinOnWatch: Bool = false
var onlyAutotuneBasals: Bool = false
var overrideFactor: Decimal = 0.8
var useCalc: Bool = false
var fattyMeals: Bool = false
var fattyMealFactor: Decimal = 0.7
}

extension FreeAPSSettings: Decodable {
Expand Down Expand Up @@ -139,6 +143,22 @@ extension FreeAPSSettings: Decodable {
settings.individualAdjustmentFactor = individualAdjustmentFactor
}

if let useCalc = try? container.decode(Bool.self, forKey: .useCalc) {
settings.useCalc = useCalc
}

if let fattyMeals = try? container.decode(Bool.self, forKey: .fattyMeals) {
settings.fattyMeals = fattyMeals
}

if let fattyMealFactor = try? container.decode(Decimal.self, forKey: .fattyMealFactor) {
settings.fattyMealFactor = fattyMealFactor
}

if let overrideFactor = try? container.decode(Decimal.self, forKey: .overrideFactor) {
settings.overrideFactor = overrideFactor
}

if let timeCap = try? container.decode(Int.self, forKey: .timeCap) {
settings.timeCap = timeCap
}
Expand Down
6 changes: 6 additions & 0 deletions FreeAPS/Sources/Modules/Bolus/BolusProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ extension Bolus {
storage.retrieve(OpenAPS.Enact.suggested, as: Suggestion.self)
}

func getProfile() -> CarbRatios {
storage.retrieve(OpenAPS.Settings.carbRatios, as: CarbRatios.self)
?? CarbRatios(from: OpenAPS.defaults(for: OpenAPS.Settings.carbRatios))
?? CarbRatios(units: .grams, schedule: [])
}

func pumpSettings() -> PumpSettings {
storage.retrieve(OpenAPS.Settings.settings, as: PumpSettings.self)
?? PumpSettings(from: OpenAPS.defaults(for: OpenAPS.Settings.settings))
Expand Down
Loading