From 906d22c350b44f0b3d6b85b06e42dcd56b439e03 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 26 Nov 2023 17:50:10 -0800 Subject: [PATCH] Update some intervals, throw out the last postion log if the latest one is < 10 meters away. --- Meshtastic/Enums/AppSettingsEnums.swift | 3 --- Meshtastic/Enums/DisplayEnums.swift | 3 +++ Meshtastic/Persistence/UpdateCoreData.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Meshtastic/Enums/AppSettingsEnums.swift b/Meshtastic/Enums/AppSettingsEnums.swift index d2d13979..dd0a94ed 100644 --- a/Meshtastic/Enums/AppSettingsEnums.swift +++ b/Meshtastic/Enums/AppSettingsEnums.swift @@ -85,7 +85,6 @@ enum UserTrackingModes: Int, CaseIterable, Identifiable { } enum LocationUpdateInterval: Int, CaseIterable, Identifiable { - case fiveSeconds = 5 case tenSeconds = 10 case fifteenSeconds = 15 case thirtySeconds = 30 @@ -97,8 +96,6 @@ enum LocationUpdateInterval: Int, CaseIterable, Identifiable { var id: Int { self.rawValue } var description: String { switch self { - case .fiveSeconds: - return "interval.five.seconds".localized case .tenSeconds: return "interval.ten.seconds".localized case .fifteenSeconds: diff --git a/Meshtastic/Enums/DisplayEnums.swift b/Meshtastic/Enums/DisplayEnums.swift index e227fdc2..afecb6ec 100644 --- a/Meshtastic/Enums/DisplayEnums.swift +++ b/Meshtastic/Enums/DisplayEnums.swift @@ -73,6 +73,7 @@ enum ScreenOnIntervals: Int, CaseIterable, Identifiable { enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable { case off = 0 + case fifteenSeconds = 15 case thirtySeconds = 30 case oneMinute = 60 case fiveMinutes = 300 @@ -84,6 +85,8 @@ enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable { switch self { case .off: return "off".localized + case .fifteenSeconds: + return "interval.fifteen.seconds".localized case .thirtySeconds: return "interval.thirty.seconds".localized case .oneMinute: diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index d210cb0d..a02837c3 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -256,10 +256,10 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext) guard let mutablePositions = fetchedNode[0].positions!.mutableCopy() as? NSMutableOrderedSet else { return } - /// Don't save the same position over and over. + /// Don't save nearly the same position over and over. If the next position is less than 10 meters from the new position, delete the previous position and save the new one. if mutablePositions.count > 0 { let mostRecent = mutablePositions.lastObject as! PositionEntity - if mostRecent.latitudeI == position.latitudeI && mostRecent.longitudeI == position.longitudeI { + if mostRecent.coordinate.distance(from: position.coordinate) < 10 { mutablePositions.remove(mostRecent) } }