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

Add a setting to limit maximum Insulin on Board #707

Closed
wants to merge 9 commits into from
1 change: 1 addition & 0 deletions Common/Extensions/NSUserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extension UserDefaults {
glucoseTargetRangeSchedule: glucoseTargetRangeSchedule,
maximumBasalRatePerHour: maximumBasalRatePerHour,
maximumBolus: maximumBolus,
maximumInsulinOnBoard: nil,
suspendThreshold: suspendThreshold,
retrospectiveCorrectionEnabled: bool(forKey: "com.loudnate.Loop.RetrospectiveCorrectionEnabled")
)
Expand Down
4 changes: 4 additions & 0 deletions Common/Models/LoopSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct LoopSettings {
var maximumBasalRatePerHour: Double?

var maximumBolus: Double?

var maximumInsulinOnBoard: Double?

var suspendThreshold: GlucoseThreshold? = nil

Expand Down Expand Up @@ -59,6 +61,7 @@ extension LoopSettings: RawRepresentable {

self.maximumBasalRatePerHour = rawValue["maximumBasalRatePerHour"] as? Double

self.maximumInsulinOnBoard = rawValue["maximumInsulinOnBoard"] as? Double
self.maximumBolus = rawValue["maximumBolus"] as? Double

if let rawThreshold = rawValue["minimumBGGuard"] as? GlucoseThreshold.RawValue {
Expand All @@ -79,6 +82,7 @@ extension LoopSettings: RawRepresentable {

raw["glucoseTargetRangeSchedule"] = glucoseTargetRangeSchedule?.rawValue
raw["maximumBasalRatePerHour"] = maximumBasalRatePerHour
raw["maximumInsulinOnBoard"] = maximumInsulinOnBoard
raw["maximumBolus"] = maximumBolus
raw["minimumBGGuard"] = suspendThreshold?.rawValue

Expand Down
Loading