Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… OmniKit PR #9 & Artificial-Pancreas#18 and MinimedKit PR #6 (Artificial-Pancreas#438)

+ Extend low reservoir notification range
+ Prevent negative duration doses, which can happen if the phone clock is changed
+ Fixes Loop crash when changing time back and cancelling bolus, Loop Issue #2057
  • Loading branch information
itsmojo authored and mountrcg committed Dec 30, 2023
1 parent 4c647d6 commit ea4c6f6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ public struct UnfinalizedDose: RawRepresentable, Equatable, CustomStringConverti

let programmedUnits = units
self.programmedUnits = programmedUnits
let newDuration = date.timeIntervalSince(startTime)

// Guard against negative duration if clock has changed
let newDuration = max(0, date.timeIntervalSince(startTime))

switch doseType {
case .bolus:
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/OmniBLE/OmniBLE/OmnipodCommon/Pod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public struct Pod {
public static let defaultLowReservoirReminder: Double = 10

// Allowed Low Reservoir reminder values
public static let allowedLowReservoirReminderValues = Array(stride(from: 10, through: 50, by: 1))
public static let allowedLowReservoirReminderValues = Array(stride(from: 1, through: 50, by: 1))
}

// DeliveryStatus used in StatusResponse and DetailedStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public struct UnfinalizedDose: RawRepresentable, Equatable, CustomStringConverti
}

scheduledUnits = units
let newDuration = date.timeIntervalSince(startTime)

// Guard against negative duration if clock has changed
let newDuration = max(0, date.timeIntervalSince(startTime))

switch doseType {
case .bolus:
Expand Down
2 changes: 1 addition & 1 deletion Dependencies/OmniKit/OmniKit/OmnipodCommon/Pod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public struct Pod {
public static let defaultLowReservoirReminder: Double = 10

// Allowed Low Reservoir reminder values
public static let allowedLowReservoirReminderValues = Array(stride(from: 10, through: 50, by: 1))
public static let allowedLowReservoirReminderValues = Array(stride(from: 1, through: 50, by: 1))
}

// DeliveryStatus used in StatusResponse and DetailedStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public struct UnfinalizedDose: RawRepresentable, Equatable, CustomStringConverti
}

scheduledUnits = units
let newDuration = date.timeIntervalSince(startTime)

// Guard against negative duration if clock has changed
let newDuration = max(0, date.timeIntervalSince(startTime))

switch doseType {
case .bolus:
Expand Down

0 comments on commit ea4c6f6

Please sign in to comment.