Skip to content

Commit 6ad0bba

Browse files
committed
Using the configured workout range from LoopKit
1 parent 52977a5 commit 6ad0bba

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github "amplitude/Amplitude-iOS" "a3d6720626e72a678489bce83ed9dacadb505dd7"
22
github "loudnate/Crypto" "13fee45175b88629aeabe60b4b4fc3daf86fa0a3"
3-
github "loudnate/LoopKit" "370afac5dd1bd700cf1c57297106f3378d56ff1b"
3+
github "loudnate/LoopKit" "d853848428ddffde2c4341fa39e8ccb754fda24d"
44
github "loudnate/SwiftCharts" "8671287afb29640f9cffced6521b1098b7aac085"
55
github "mddub/dexcom-share-client-swift" "v0.1.3"
66
github "loudnate/xDripG5" "0.5.0"

Loop/Managers/DeviceDataManager.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ class DeviceDataManager: CarbStoreDelegate, TransmitterDelegate {
583583
}
584584

585585
if let glucoseTargetRangeSchedule = glucoseTargetRangeSchedule {
586-
self.glucoseTargetRangeSchedule = GlucoseRangeSchedule(unit: glucoseTargetRangeSchedule.unit, dailyItems: glucoseTargetRangeSchedule.items, timeZone: pumpTimeZone)
586+
self.glucoseTargetRangeSchedule = GlucoseRangeSchedule(unit: glucoseTargetRangeSchedule.unit, dailyItems: glucoseTargetRangeSchedule.items, workoutRange: glucoseTargetRangeSchedule.workoutRange, timeZone: pumpTimeZone)
587587
}
588588
}
589589
case "pumpModel"?:
@@ -720,15 +720,8 @@ class DeviceDataManager: CarbStoreDelegate, TransmitterDelegate {
720720
return false
721721
}
722722

723-
// Hardcoded: 160-180 mg/dL for 1 hour.
724-
let endDate = NSDate(timeIntervalSinceNow: NSTimeInterval(hours: 1))
725-
let unit = HKUnit.milligramsPerDeciliterUnit()
726-
let targets = DoubleRange(
727-
minValue: HKQuantity(unit: unit, doubleValue: 160).doubleValueForUnit(glucoseTargetRangeSchedule.unit),
728-
maxValue: HKQuantity(unit: unit, doubleValue: 180).doubleValueForUnit(glucoseTargetRangeSchedule.unit)
729-
)
730-
731-
glucoseTargetRangeSchedule.setOverride(targets, untilDate: endDate)
723+
let endDate = NSDate(timeIntervalSinceNow: duration)
724+
glucoseTargetRangeSchedule.setWorkoutOverrideUntilDate(endDate)
732725

733726
NSNotificationCenter.defaultCenter().postNotificationName(self.dynamicType.LoopSettingsUpdatedNotification, object: self)
734727

Loop/Managers/StatusChartManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class StatusChartsManager {
236236
let allPoints = glucosePoints + predictedGlucosePoints
237237

238238
// TODO: The segment/multiple values are unit-specific
239-
let yAxisValues = ChartAxisValuesGenerator.generateYAxisValuesWithChartPoints(allPoints + targetGlucosePoints, minSegmentCount: 2, maxSegmentCount: 4, multiple: 25, axisValueGenerator: { ChartAxisValueDouble($0, labelSettings: self.axisLabelSettings) }, addPaddingSegmentIfEdge: true)
239+
let yAxisValues = ChartAxisValuesGenerator.generateYAxisValuesWithChartPoints(allPoints + targetGlucosePoints + targetOverridePoints, minSegmentCount: 2, maxSegmentCount: 4, multiple: 25, axisValueGenerator: { ChartAxisValueDouble($0, labelSettings: self.axisLabelSettings) }, addPaddingSegmentIfEdge: true)
240240

241241
let yAxisModel = ChartAxisModel(axisValues: yAxisValues, lineColor: axisLineColor)
242242

Loop/View Controllers/SettingsTableViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class SettingsTableViewController: UITableViewController, DailyValueScheduleTabl
425425
scheduleVC.timeZone = schedule.timeZone
426426
scheduleVC.scheduleItems = schedule.items
427427
scheduleVC.unit = schedule.unit
428+
scheduleVC.workoutRange = schedule.workoutRange
428429

429430
showViewController(scheduleVC, sender: sender)
430431
} else if let glucoseStore = dataManager.glucoseStore {
@@ -583,7 +584,7 @@ class SettingsTableViewController: UITableViewController, DailyValueScheduleTabl
583584
}
584585
case .GlucoseTargetRange:
585586
if let controller = controller as? GlucoseRangeScheduleTableViewController {
586-
dataManager.glucoseTargetRangeSchedule = GlucoseRangeSchedule(unit: controller.unit, dailyItems: controller.scheduleItems, timeZone: controller.timeZone)
587+
dataManager.glucoseTargetRangeSchedule = GlucoseRangeSchedule(unit: controller.unit, dailyItems: controller.scheduleItems, workoutRange: controller.workoutRange, timeZone: controller.timeZone)
587588
}
588589
case let row:
589590
if let controller = controller as? DailyQuantityScheduleTableViewController {

0 commit comments

Comments
 (0)