Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion LoopFollow/Controllers/Nightscout/DeviceStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension MainViewController {
func updateDeviceStatusDisplay(jsonDeviceStatus: [[String: AnyObject]]) {
let previousIOBText = Observable.shared.iobText.value
let previousDeviceWasLoop = Storage.shared.device.value == "Loop"
infoManager.clearInfoData(types: [.iob, .cob, .battery, .pump, .pumpBattery, .target, .isf, .carbRatio, .updated, .recBolus, .tdd, .smoothedBG])
infoManager.clearInfoData(types: [.iob, .cob, .battery, .pump, .pumpBattery, .target, .isf, .carbRatio, .updated, .recBolus, .tdd, .smoothedBG, .watchBattery])

// For Loop, clear the current override here - For Trio, it is handled using treatments
if Storage.shared.device.value == "Loop" {
Expand Down Expand Up @@ -184,6 +184,15 @@ extension MainViewController {
deviceBatteryData.removeFirst()
}
}

// Trio adds the Apple Watch's battery while the watch reported it within the last hour
if let watch = lastDeviceStatus?["watchBattery"] as? [String: AnyObject],
let level = (watch["battery"] as? NSNumber)?.doubleValue
{
let charging = watch["isCharging"] as? Bool == true
let text = (charging ? "⚡️ " : "") + String(format: "%.0f", level) + "%"
infoManager.updateInfoData(type: .watchBattery, value: text, numericValue: level)
}
}

// Loop - handle new data
Expand Down
5 changes: 3 additions & 2 deletions LoopFollow/InfoTable/InfoType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Foundation

enum InfoType: Int, CaseIterable, Codable {
case iob, cob, basal, override, battery, pump, pumpBattery, sage, cage, recBolus, minMax, carbsToday, autosens, profile, target, isf, carbRatio, updated, tdd, iage, dbSize, smoothedBG
case iob, cob, basal, override, battery, pump, pumpBattery, sage, cage, recBolus, minMax, carbsToday, autosens, profile, target, isf, carbRatio, updated, tdd, iage, dbSize, smoothedBG, watchBattery

var name: String {
switch self {
Expand All @@ -30,6 +30,7 @@ enum InfoType: Int, CaseIterable, Codable {
case .iage: return "IAGE"
case .dbSize: return "DB Size"
case .smoothedBG: return "Smoothed BG"
case .watchBattery: return "Watch Battery"
}
}

Expand Down Expand Up @@ -57,7 +58,7 @@ enum InfoType: Int, CaseIterable, Codable {
return InfoColorConfig(direction: .above, unit: "U", range: 0 ... 20, step: 0.5, defaultWarning: 3, defaultUrgent: 5)
case .cob:
return InfoColorConfig(direction: .above, unit: "g", range: 0 ... 200, step: 1, defaultWarning: 30, defaultUrgent: 60)
case .battery, .pumpBattery:
case .battery, .pumpBattery, .watchBattery:
return InfoColorConfig(direction: .below, unit: "%", range: 0 ... 100, step: 5, defaultWarning: 30, defaultUrgent: 15)
case .pump:
return InfoColorConfig(direction: .below, unit: "U", range: 0 ... 50, step: 1, defaultWarning: 20, defaultUrgent: 10)
Expand Down