Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e14f9da
Add a setting to limit maximum Insulin on Board
erikdi Apr 26, 2018
fb22de4
Cosmetics
erikdi Apr 26, 2018
800215a
Two more cosmetic fixes.
erikdi Apr 26, 2018
77d501c
Refactor Bolus Recommendation
erikdi Apr 26, 2018
e327327
Remove recommendBolus function from LoopState
erikdi Apr 26, 2018
449b3d8
Merge branch 'wip/iob' into wip/auto
erikdi May 4, 2018
25817d9
Factor out automated Bolus code
erikdi May 4, 2018
1107c6e
Remove merge artifacts.
erikdi May 4, 2018
634cf14
Fix merged data to actually give a bolus recommendation and deliver t…
erikdi May 4, 2018
a8ec1ff
Document new lowerOnly parameter
erikdi May 4, 2018
9ae7b9c
Document parameters to enactBolus and add a thought about a critical …
erikdi May 4, 2018
9e0af1c
Remove unused setting.
erikdi May 4, 2018
6376b99
Merge remote-tracking branch 'upstream/dev' into wip/iob
erikdi Jun 15, 2018
2b44238
Merge branch 'wip/iob' into wip/auto
erikdi Jun 15, 2018
7540620
Add maximum Insulin on board protection to Bolus dialog as well.
erikdi Jun 15, 2018
f2a66b6
Improve error message for IOB validation.
erikdi Jun 15, 2018
5add79f
Merge branch 'wip/iob' into wip/auto
erikdi Jun 15, 2018
c5e32b2
Merge remote-tracking branch 'upstream/dev' into wip/iob
erikdi Jun 22, 2018
083a65b
Merge branch 'wip/iob' into wip/auto
erikdi Jun 22, 2018
353e9d5
Fix test code after merge
erikdi Jun 23, 2018
3c9a382
Merge branch 'wip/iob' into wip/auto
erikdi Jun 23, 2018
b0fb27e
Fix merge with latest upstream/dev
erikdi Jun 23, 2018
d60744d
Re-add diagnostic report entries which were accidentally removed duri…
erikdi Jun 24, 2018
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
2 changes: 2 additions & 0 deletions Common/Extensions/NSUserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ extension UserDefaults {

let settings = LoopSettings(
dosingEnabled: bool(forKey: "com.loudnate.Naterade.DosingEnabled"),
bolusEnabled: false,
glucoseTargetRangeSchedule: glucoseTargetRangeSchedule,
maximumBasalRatePerHour: maximumBasalRatePerHour,
maximumBolus: maximumBolus,
maximumInsulinOnBoard: nil,
suspendThreshold: suspendThreshold,
retrospectiveCorrectionEnabled: bool(forKey: "com.loudnate.Loop.RetrospectiveCorrectionEnabled")
)
Expand Down
16 changes: 16 additions & 0 deletions Common/Models/LoopSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@ import RileyLinkBLEKit
struct LoopSettings {
var dosingEnabled = false

var bolusEnabled = false

let dynamicCarbAbsorptionEnabled = true

var glucoseTargetRangeSchedule: GlucoseRangeSchedule?

var maximumBasalRatePerHour: Double?

var maximumBolus: Double?

var maximumInsulinOnBoard: Double?

var suspendThreshold: GlucoseThreshold? = nil

var retrospectiveCorrectionEnabled = true

// For the automated Bolus functionality.
let automatedBolusThreshold: Double = 0.1
let automatedBolusRatio: Double = 0.7
let automaticBolusInterval: TimeInterval = TimeInterval(minutes: 7)

let retrospectiveCorrectionInterval = TimeInterval(minutes: 30)

/// The amount of time since a given date that data should be considered valid
Expand Down Expand Up @@ -52,13 +61,18 @@ extension LoopSettings: RawRepresentable {
if let dosingEnabled = rawValue["dosingEnabled"] as? Bool {
self.dosingEnabled = dosingEnabled
}

if let bolusEnabled = rawValue["bolusEnabled"] as? Bool {
self.bolusEnabled = bolusEnabled
}

if let rawValue = rawValue["glucoseTargetRangeSchedule"] as? GlucoseRangeSchedule.RawValue {
self.glucoseTargetRangeSchedule = GlucoseRangeSchedule(rawValue: rawValue)
}

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 @@ -74,11 +88,13 @@ extension LoopSettings: RawRepresentable {
var raw: RawValue = [
"version": LoopSettings.version,
"dosingEnabled": dosingEnabled,
"bolusEnabled": bolusEnabled,
"retrospectiveCorrectionEnabled": retrospectiveCorrectionEnabled
]

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

Expand Down
Loading