|
|
@@ -1,10 +1,12 @@
|
|
|
import Foundation
|
|
|
+import LoopKit
|
|
|
import Swinject
|
|
|
|
|
|
protocol SettingsManager: AnyObject {
|
|
|
var settings: FreeAPSSettings { get set }
|
|
|
var preferences: Preferences { get }
|
|
|
var pumpSettings: PumpSettings { get }
|
|
|
+ func updateInsulinCurve(_ insulinType: InsulinType?)
|
|
|
}
|
|
|
|
|
|
protocol SettingsObserver {
|
|
|
@@ -52,4 +54,23 @@ final class BaseSettingsManager: SettingsManager, Injectable {
|
|
|
?? PumpSettings(from: OpenAPS.defaults(for: OpenAPS.Settings.settings))
|
|
|
?? PumpSettings(insulinActionCurve: 5, maxBolus: 10, maxBasal: 2)
|
|
|
}
|
|
|
+
|
|
|
+ func updateInsulinCurve(_ insulinType: InsulinType?) {
|
|
|
+ var prefs = preferences
|
|
|
+
|
|
|
+ switch insulinType {
|
|
|
+ case .apidra,
|
|
|
+ .humalog,
|
|
|
+ .novolog:
|
|
|
+ prefs.curve = .rapidActing
|
|
|
+
|
|
|
+ case .afrezza,
|
|
|
+ .fiasp,
|
|
|
+ .lyumjev:
|
|
|
+ prefs.curve = .ultraRapid
|
|
|
+ default:
|
|
|
+ prefs.curve = .rapidActing
|
|
|
+ }
|
|
|
+ storage.save(prefs, as: OpenAPS.Settings.preferences)
|
|
|
+ }
|
|
|
}
|