Ivan Valkou 4 лет назад
Родитель
Сommit
68c7b3cda7

+ 1 - 1
FreeAPS.xcodeproj/project.pbxproj

@@ -1074,7 +1074,6 @@
 		388E5A5A25B6F05F0019842D /* Helpers */ = {
 		388E5A5A25B6F05F0019842D /* Helpers */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
-				38FEF412273B317A00574A46 /* HKUnit.swift */,
 				38F37827261260DC009DB701 /* Color+Extensions.swift */,
 				38F37827261260DC009DB701 /* Color+Extensions.swift */,
 				389ECE042601144100D86C4F /* ConcurrentMap.swift */,
 				389ECE042601144100D86C4F /* ConcurrentMap.swift */,
 				38192E0C261BAF980094D973 /* ConvenienceExtensions.swift */,
 				38192E0C261BAF980094D973 /* ConvenienceExtensions.swift */,
@@ -1082,6 +1081,7 @@
 				38C4D33625E9A1A200D30B77 /* DispatchQueue+Extensions.swift */,
 				38C4D33625E9A1A200D30B77 /* DispatchQueue+Extensions.swift */,
 				389487392614928B004DF424 /* DispatchTimer.swift */,
 				389487392614928B004DF424 /* DispatchTimer.swift */,
 				3811DE5425C9D4D500A708ED /* Formatters.swift */,
 				3811DE5425C9D4D500A708ED /* Formatters.swift */,
+				38FEF412273B317A00574A46 /* HKUnit.swift */,
 				38B4F3AE25E2979F00E76A18 /* IndexedCollection.swift */,
 				38B4F3AE25E2979F00E76A18 /* IndexedCollection.swift */,
 				389A571F26079BAA00BC102F /* Interpolation.swift */,
 				389A571F26079BAA00BC102F /* Interpolation.swift */,
 				388E5A5B25B6F0770019842D /* JSON.swift */,
 				388E5A5B25B6F0770019842D /* JSON.swift */,

+ 3 - 1
FreeAPS/Sources/APS/CGM/Calibrations/CalibrationService.swift

@@ -31,6 +31,8 @@ final class BaseCalibrationService: CalibrationService, Injectable {
         static let maxSlope = 1.25
         static let maxSlope = 1.25
         static let minIntercept = -100.0
         static let minIntercept = -100.0
         static let maxIntercept = 100.0
         static let maxIntercept = 100.0
+        static let maxValue = 400.0
+        static let minValue = 40.0
     }
     }
 
 
     @Injected() var storage: FileStorage!
     @Injected() var storage: FileStorage!
@@ -112,6 +114,6 @@ final class BaseCalibrationService: CalibrationService, Injectable {
     }
     }
 
 
     private func linearRegression(_ x: Double) -> Double {
     private func linearRegression(_ x: Double) -> Double {
-        intercept + slope * x
+        (intercept + slope * x).clamped(Config.minValue ... Config.maxValue)
     }
     }
 }
 }