Prechádzať zdrojové kódy

Fix calibrations for Libre2 sensors

Ivan Valkou 4 rokov pred
rodič
commit
b8a0956b15

+ 11 - 3
Dependencies/LibreTransmitter/Sources/LibreTransmitter/LibreTransmitterManager.swift

@@ -447,7 +447,7 @@ extension LibreTransmitterManager {
             glucose += LibreGlucose.fromHistoryMeasurements(sortedHistory, nativeCalibrationData: calibrationData)
         }*/
 
-        let newGlucose = glucosesToSamplesFilter(glucose, startDate: getStartDateForFilter())
+        var newGlucose = glucosesToSamplesFilter(glucose, startDate: getStartDateForFilter())
 
         if newGlucose.isEmpty {
             self.countTimesWithoutData &+= 1
@@ -459,6 +459,10 @@ extension LibreTransmitterManager {
 
         //todo: predictions also for libre2 bluetooth data
         //self.latestPrediction = prediction?.first
+        var predictions: [LibreGlucose] = []
+
+        overcalibrate(entries: &newGlucose, prediction: &predictions)
+
         self.setObservables(sensorData: nil, bleData: bleData, metaData: device)
 
         self.logger.debug("dabear:: handleGoodReading returned with \(newGlucose.count) entries")
@@ -638,6 +642,12 @@ extension LibreTransmitterManager {
             entries += LibreGlucose.fromHistoryMeasurements(history, nativeCalibrationData: calibration)
         }
 
+        overcalibrate(entries: &entries, prediction: &prediction)
+
+        return (glucose: entries, prediction: prediction)
+    }
+
+    private func overcalibrate(entries: inout [LibreGlucose], prediction: inout [LibreGlucose]) {
         // overcalibrate
         var overcalibration: ((Double) -> (Double))? = nil
         delegateQueue.sync { overcalibration = cgmManagerDelegate?.overcalibration(for: self) }
@@ -654,8 +664,6 @@ extension LibreTransmitterManager {
             entries = overcalibrate(entries: entries)
             prediction = overcalibrate(entries: prediction)
         }
-
-        return (glucose: entries, prediction: prediction)
     }
 
     public func handleGoodReading(data: SensorData?, _ callback: @escaping (LibreError?, GlucoseArrayWithPrediction?) -> Void) {

+ 6 - 19
FreeAPS.xcodeproj/xcshareddata/xcschemes/FreeAPSWatch.xcscheme

@@ -55,10 +55,8 @@
       debugServiceExtension = "internal"
       allowLocationSimulation = "YES"
       notificationPayloadFile = "FreeAPSWatch WatchKit Extension/PushNotificationPayload.apns">
-      <RemoteRunnable
-         runnableDebuggingMode = "2"
-         BundleIdentifier = "com.apple.Carousel"
-         RemotePath = "/FreeAPS X">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "38E8751B27554D5500975559"
@@ -66,7 +64,7 @@
             BlueprintName = "FreeAPSWatch"
             ReferencedContainer = "container:FreeAPS.xcodeproj">
          </BuildableReference>
-      </RemoteRunnable>
+      </BuildableProductRunnable>
    </LaunchAction>
    <ProfileAction
       buildConfiguration = "Release"
@@ -74,10 +72,8 @@
       savedToolIdentifier = ""
       useCustomWorkingDirectory = "NO"
       debugDocumentVersioning = "YES">
-      <RemoteRunnable
-         runnableDebuggingMode = "2"
-         BundleIdentifier = "com.apple.Carousel"
-         RemotePath = "/FreeAPS X">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "38E8751B27554D5500975559"
@@ -85,16 +81,7 @@
             BlueprintName = "FreeAPSWatch"
             ReferencedContainer = "container:FreeAPS.xcodeproj">
          </BuildableReference>
-      </RemoteRunnable>
-      <MacroExpansion>
-         <BuildableReference
-            BuildableIdentifier = "primary"
-            BlueprintIdentifier = "38E8751B27554D5500975559"
-            BuildableName = "FreeAPSWatch.app"
-            BlueprintName = "FreeAPSWatch"
-            ReferencedContainer = "container:FreeAPS.xcodeproj">
-         </BuildableReference>
-      </MacroExpansion>
+      </BuildableProductRunnable>
    </ProfileAction>
    <AnalyzeAction
       buildConfiguration = "Debug">