-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from ps2/dev
v0.9.0
- Loading branch information
Showing
27 changed files
with
182 additions
and
858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// PredictedBG.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 8/8/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import HealthKit | ||
|
||
public struct PredictedBG { | ||
let values: [Int] | ||
let cob: [Int]? | ||
let iob: [Int]? | ||
|
||
public init(values: [HKQuantity], cob: [HKQuantity]? = nil, iob: [HKQuantity]? = nil) { | ||
// BG values in nightscout are in mg/dL. | ||
let unit = HKUnit.milligramsPerDeciliterUnit() | ||
self.values = values.map { Int(round($0.doubleValueForUnit(unit))) } | ||
self.cob = cob?.map { Int(round($0.doubleValueForUnit(unit))) } | ||
self.iob = iob?.map { Int(round($0.doubleValueForUnit(unit))) } | ||
} | ||
|
||
public var dictionaryRepresentation: [String: AnyObject] { | ||
|
||
var rval = [String: AnyObject]() | ||
|
||
rval["values"] = values | ||
|
||
if let cob = cob { | ||
rval["COB"] = cob | ||
} | ||
|
||
if let iob = iob { | ||
rval["IOB"] = iob | ||
} | ||
|
||
return rval | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// HKUnit.swift | ||
// RileyLink | ||
// | ||
// Created by Nate Racklyeft on 8/8/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import HealthKit | ||
|
||
|
||
extension HKUnit { | ||
static func milligramsPerDeciliterUnit() -> HKUnit { | ||
return HKUnit.gramUnitWithMetricPrefix(.Milli).unitDividedByUnit(HKUnit.literUnitWithMetricPrefix(.Deci)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.