Skip to content

Commit 755b4d0

Browse files
jlucasvtloudnate
authored andcommitted
Update for x22 Pumps to Display Reservoir Status HUD (#71)
* Update for x22 Pumps to Display Reservoir Status HUD This branch commit encapsulates the Update to allow x22 pumps to display the Reservoir Status in the HUD. Added PumpModel.swift Extension, Updated Logic and tested values.
1 parent 17c6f62 commit 755b4d0

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Loop.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
43F78D4E1C914197002152D1 /* InsulinKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43F78D4A1C914197002152D1 /* InsulinKit.framework */; };
137137
43F78D4F1C914197002152D1 /* LoopKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43F78D4B1C914197002152D1 /* LoopKit.framework */; };
138138
C10428971D17BAD400DD539A /* NightscoutUploadKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C10428961D17BAD400DD539A /* NightscoutUploadKit.framework */; };
139+
C51F56121D3B91CD004C46ED /* PumpModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51F56111D3B91CD004C46ED /* PumpModel.swift */; };
139140
/* End PBXBuildFile section */
140141

141142
/* Begin PBXContainerItemProxy section */
@@ -350,6 +351,7 @@
350351
43F78D4A1C914197002152D1 /* InsulinKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = InsulinKit.framework; path = Carthage/Build/iOS/InsulinKit.framework; sourceTree = "<group>"; };
351352
43F78D4B1C914197002152D1 /* LoopKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LoopKit.framework; path = Carthage/Build/iOS/LoopKit.framework; sourceTree = "<group>"; };
352353
C10428961D17BAD400DD539A /* NightscoutUploadKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NightscoutUploadKit.framework; path = Carthage/Build/iOS/NightscoutUploadKit.framework; sourceTree = "<group>"; };
354+
C51F56111D3B91CD004C46ED /* PumpModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PumpModel.swift; sourceTree = "<group>"; };
353355
/* End PBXFileReference section */
354356

355357
/* Begin PBXFrameworksBuildPhase section */
@@ -573,6 +575,7 @@
573575
43E344A01B9E144300C85C07 /* Extensions */ = {
574576
isa = PBXGroup;
575577
children = (
578+
C51F56111D3B91CD004C46ED /* PumpModel.swift */,
576579
4331E0771C85302200FBE832 /* CGPoint.swift */,
577580
4346D1F51C78501000ABAFE3 /* ChartPoint.swift */,
578581
43649A621C7A347F00523D7F /* CollectionType.swift */,
@@ -949,6 +952,7 @@
949952
buildActionMask = 2147483647;
950953
files = (
951954
434F54571D287FDB002A9274 /* NibLoadable.swift in Sources */,
955+
C51F56121D3B91CD004C46ED /* PumpModel.swift in Sources */,
952956
4315D28A1CA5F45E00589052 /* DiagnosticLogger+LoopKit.swift in Sources */,
953957
43C418B51CE0575200405B6A /* ShareGlucose+GlucoseKit.swift in Sources */,
954958
434F24C91CFCA8940004498F /* TransmitterGlucose.swift in Sources */,

Loop/Extensions/PumpModel.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// PumpModel.swift
3+
// Loop
4+
//
5+
// Created by Jerermy Lucas on 7/16/16.
6+
// Copyright © 2016 Nathan Racklyeft. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import MinimedKit
11+
12+
extension PumpModel {
13+
private var size: Int {
14+
return Int(rawValue)! / 100
15+
}
16+
17+
var reservoirCapacity: Double {
18+
switch size {
19+
case 5:
20+
return 176
21+
case 7:
22+
return 300
23+
default:
24+
fatalError("Unknown reservoir capacity for PumpModel.\(self)")
25+
}
26+
}
27+
}

Loop/View Controllers/StatusTableViewController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,12 @@ class StatusTableViewController: UITableViewController, UIGestureRecognizerDeleg
206206
}
207207

208208
reservoirVolume = dataManager.latestReservoirValue?.unitVolume
209-
209+
210+
if let capacity = dataManager.pumpState?.pumpModel?.reservoirCapacity,
211+
resVol = reservoirVolume {
212+
reservoirLevel = min(1, max(0, Double(resVol / capacity)))
213+
}
214+
210215
if let status = dataManager.latestPumpStatus {
211216
reservoirLevel = Double(status.reservoirRemainingPercent) / 100
212217
batteryLevel = Double(status.batteryRemainingPercent) / 100

0 commit comments

Comments
 (0)