Skip to content

Conversation

@jlucasvt
Copy link
Contributor

New PR for #141 Updated to now allow for discrete selection of Alkaline and LIthium battery chemistry. View Controller and Enum added to allow for named selection following pattern of preferredInsulinDataSource.

img_6206

- Added Battery Chemistry Selection in SettingsTableViewController
- Add User Var to store the Battery Chemistry Setting
- Added defaults and Enum for Battery Chemistry Type
- Added Battery Calculation
- Hide Setting for Battery Type on MySentry Pumps
- Updated Switch Descriptions and Alkaline syntax
Copy link
Collaborator

@ps2 ps2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update Jeremy. Looks really good. You can just update the branch, and not submit a new PR.

if (self.batteryChemistry == .lithium){
minVoltage = 1.32
maxVoltage = 1.58
batteryNotification = 0.12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point at which we display 0% battery should be equal the point at which a notification should be made, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of this Notification was to "warn" a user of an impending battery failure or intermittent communications failures due to low battery. This is a 8 to 12 hour warning prior to battery = 0.

https://docs.google.com/spreadsheets/d/19FpO5YO5ewQrdph_4iIXuear6xRGzl-AYTiFeHwPcVk/edit#gid=246762532.

///
/// - parameter currVoltage: Current Voltage Reading from Pump
///
public var x22BatteryPercentRemaining : Double = -1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already have a battery % for x23 devices, let's track battery % as a single ivar.

Updating that ivar can trigger both battery change event (AnalyticsManager.sharedManager.pumpBatteryWasReplaced()) and notification (NotificationManager.sendPumpBatteryLowNotification()), and then the StatusTableViewController can check one place for battery percent, instead of checking both dataManager.latestPumpStatusFromMySentry.batteryRemainingPercent and dataManager.x22BatteryPercentRemaining

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use magic number sentinels; use an optional.
Since percentage is derived from chemistry, and chemistry can be changed at any time, this shouldn't be stored at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it you are saying I should write the Battery % Remaining to dataManager.latestPumpStatusFromMySentry.batteryRemainingPercent. I totally agree reuse of the already existing structure would be great, however I am unsure how to write to the batteryRemainingPercent var.

latestPumpStatusFromMySentry?.batteryRemainingPercent = ((currVoltage - minVoltage)/(maxVoltage - minVoltage))

I receive an error

Cannot assign to property: 'batteryRemainingPercent' is a 'let' constant

@@ -0,0 +1,86 @@
//
// BatteryTypeSelectionTableViewController.swift
// Loop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it not possible to re-use RadioSelectionTableViewController?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure it may be. I am just not swift enough to fully comprehend how. So I leveraged the existing pattern Nate had provided.

@jlucasvt
Copy link
Contributor Author

Closed for #275

@jlucasvt jlucasvt closed this Nov 22, 2016
@jlucasvt jlucasvt deleted the dev-1.1.1-x22BatteryStatus branch March 14, 2017 12:11
ps2 pushed a commit that referenced this pull request Oct 4, 2020
* LOOP-1938: Acknowledge all given an identifier

I thought it would be sufficient to only acknowledge the latest Alert, but LOOP-1938 points out that if an alert repeats without (prior issued Alerts) getting acknowledged, those prior Alerts get "stuck" and will replay on restart until they all are acknowledged.
Becky convinced me that, conceptually, if you get multiple issues of the _same_ alert, recording an acknowledgement date on all of them is appropriate.

* checkpoint

* Unit tests & refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants