Skip to content

Commit b8a0956

Browse files
committed
Fix calibrations for Libre2 sensors
1 parent 9be9154 commit b8a0956

2 files changed

Lines changed: 17 additions & 22 deletions

File tree

Dependencies/LibreTransmitter/Sources/LibreTransmitter/LibreTransmitterManager.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ extension LibreTransmitterManager {
447447
glucose += LibreGlucose.fromHistoryMeasurements(sortedHistory, nativeCalibrationData: calibrationData)
448448
}*/
449449

450-
let newGlucose = glucosesToSamplesFilter(glucose, startDate: getStartDateForFilter())
450+
var newGlucose = glucosesToSamplesFilter(glucose, startDate: getStartDateForFilter())
451451

452452
if newGlucose.isEmpty {
453453
self.countTimesWithoutData &+= 1
@@ -459,6 +459,10 @@ extension LibreTransmitterManager {
459459

460460
//todo: predictions also for libre2 bluetooth data
461461
//self.latestPrediction = prediction?.first
462+
var predictions: [LibreGlucose] = []
463+
464+
overcalibrate(entries: &newGlucose, prediction: &predictions)
465+
462466
self.setObservables(sensorData: nil, bleData: bleData, metaData: device)
463467

464468
self.logger.debug("dabear:: handleGoodReading returned with \(newGlucose.count) entries")
@@ -638,6 +642,12 @@ extension LibreTransmitterManager {
638642
entries += LibreGlucose.fromHistoryMeasurements(history, nativeCalibrationData: calibration)
639643
}
640644

645+
overcalibrate(entries: &entries, prediction: &prediction)
646+
647+
return (glucose: entries, prediction: prediction)
648+
}
649+
650+
private func overcalibrate(entries: inout [LibreGlucose], prediction: inout [LibreGlucose]) {
641651
// overcalibrate
642652
var overcalibration: ((Double) -> (Double))? = nil
643653
delegateQueue.sync { overcalibration = cgmManagerDelegate?.overcalibration(for: self) }
@@ -654,8 +664,6 @@ extension LibreTransmitterManager {
654664
entries = overcalibrate(entries: entries)
655665
prediction = overcalibrate(entries: prediction)
656666
}
657-
658-
return (glucose: entries, prediction: prediction)
659667
}
660668

661669
public func handleGoodReading(data: SensorData?, _ callback: @escaping (LibreError?, GlucoseArrayWithPrediction?) -> Void) {

FreeAPS.xcodeproj/xcshareddata/xcschemes/FreeAPSWatch.xcscheme

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,46 +55,33 @@
5555
debugServiceExtension = "internal"
5656
allowLocationSimulation = "YES"
5757
notificationPayloadFile = "FreeAPSWatch WatchKit Extension/PushNotificationPayload.apns">
58-
<RemoteRunnable
59-
runnableDebuggingMode = "2"
60-
BundleIdentifier = "com.apple.Carousel"
61-
RemotePath = "/FreeAPS X">
58+
<BuildableProductRunnable
59+
runnableDebuggingMode = "0">
6260
<BuildableReference
6361
BuildableIdentifier = "primary"
6462
BlueprintIdentifier = "38E8751B27554D5500975559"
6563
BuildableName = "FreeAPSWatch.app"
6664
BlueprintName = "FreeAPSWatch"
6765
ReferencedContainer = "container:FreeAPS.xcodeproj">
6866
</BuildableReference>
69-
</RemoteRunnable>
67+
</BuildableProductRunnable>
7068
</LaunchAction>
7169
<ProfileAction
7270
buildConfiguration = "Release"
7371
shouldUseLaunchSchemeArgsEnv = "YES"
7472
savedToolIdentifier = ""
7573
useCustomWorkingDirectory = "NO"
7674
debugDocumentVersioning = "YES">
77-
<RemoteRunnable
78-
runnableDebuggingMode = "2"
79-
BundleIdentifier = "com.apple.Carousel"
80-
RemotePath = "/FreeAPS X">
75+
<BuildableProductRunnable
76+
runnableDebuggingMode = "0">
8177
<BuildableReference
8278
BuildableIdentifier = "primary"
8379
BlueprintIdentifier = "38E8751B27554D5500975559"
8480
BuildableName = "FreeAPSWatch.app"
8581
BlueprintName = "FreeAPSWatch"
8682
ReferencedContainer = "container:FreeAPS.xcodeproj">
8783
</BuildableReference>
88-
</RemoteRunnable>
89-
<MacroExpansion>
90-
<BuildableReference
91-
BuildableIdentifier = "primary"
92-
BlueprintIdentifier = "38E8751B27554D5500975559"
93-
BuildableName = "FreeAPSWatch.app"
94-
BlueprintName = "FreeAPSWatch"
95-
ReferencedContainer = "container:FreeAPS.xcodeproj">
96-
</BuildableReference>
97-
</MacroExpansion>
84+
</BuildableProductRunnable>
9885
</ProfileAction>
9986
<AnalyzeAction
10087
buildConfiguration = "Debug">

0 commit comments

Comments
 (0)