From 08ea85d717c4f687d8e012d8d05f51de6f3e8bb7 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 4 May 2024 16:03:38 -0700 Subject: [PATCH] Re order gps mode toggle add additional position precision options Updated fixed postion text --- Meshtastic/Enums/PositionConfigEnums.swift | 2 +- Meshtastic/Views/Settings/Channels.swift | 68 ++++++++++++++----- .../Views/Settings/Channels/ChannelForm.swift | 2 +- .../Settings/Config/PositionConfig.swift | 12 +++- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/Meshtastic/Enums/PositionConfigEnums.swift b/Meshtastic/Enums/PositionConfigEnums.swift index 0773112c..a9958c08 100644 --- a/Meshtastic/Enums/PositionConfigEnums.swift +++ b/Meshtastic/Enums/PositionConfigEnums.swift @@ -100,8 +100,8 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable { } enum GpsMode: Int, CaseIterable, Equatable { - case disabled = 0 case enabled = 1 + case disabled = 0 case notPresent = 2 var id: Int { self.rawValue } diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index b71ff400..797ee714 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -308,18 +308,52 @@ func firstMissingChannelIndex(_ indexes: [Int]) -> Int { enum PositionPrecision: Int, CaseIterable, Identifiable { + case two = 2 + case three = 3 + case four = 4 + case five = 5 + case six = 6 + case seven = 7 + case eight = 8 + case nine = 9 + case ten = 10 case eleven = 11 case twelve = 12 case thirteen = 13 case fourteen = 14 case fifteen = 15 case sixteen = 16 + case seventeen = 17 + case eightteen = 18 + case nineteen = 19 + case twenty = 20 + case twentyone = 21 + case twentytwo = 22 + case twentythree = 23 + case twentyfour = 24 var id: Int { self.rawValue } var precisionMeters: Double { switch self { - + case .two: + return 5976446.981252 + case .three: + return 2988223.4850600003 + case .four: + return 1494111.7369640006 + case .five: + return 747055.8629159998 + case .six: + return 373527.9258920002 + case .seven: + return 186763.95738000044 + case .eight: + return 93381.97312400135 + case .nine: + return 46690.98099600022 + case .ten: + return 23345.48493200123 case .eleven: return 11672.736900000944 case .twelve: @@ -332,25 +366,27 @@ enum PositionPrecision: Int, CaseIterable, Identifiable { return 729.5356200010741 case .sixteen: return 364.7622440000765 + case .seventeen: + return 182.37555600115968 + case .eightteen: + return 91.1822120001193 + case .nineteen: + return 45.58554000039009 + case .twenty: + return 22.787204001316468 + case .twentyone: + return 11.388036000988677 + case .twentytwo: + return 5.688452000824781 + case .twentythree: + return 2.8386600007428338 + case .twentyfour: + return 1.413763999910884 } } var description: String { let distanceFormatter = MKDistanceFormatter() - switch self { - - case .eleven: - return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) - case .twelve: - return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) - case .thirteen: - return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) - case .fourteen: - return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) - case .fifteen: - return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) - case .sixteen: - return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) - } + return String.localizedStringWithFormat("position.precision %@".localized, String(distanceFormatter.string(fromDistance: precisionMeters))) } } diff --git a/Meshtastic/Views/Settings/Channels/ChannelForm.swift b/Meshtastic/Views/Settings/Channels/ChannelForm.swift index cdde8442..60e1b2dd 100644 --- a/Meshtastic/Views/Settings/Channels/ChannelForm.swift +++ b/Meshtastic/Views/Settings/Channels/ChannelForm.swift @@ -160,7 +160,7 @@ struct ChannelForm: View { if !preciseLocation { VStack(alignment: .leading) { Label("Approximate Location", systemImage: "location.slash.circle.fill") - Slider(value: $positionPrecision, in: 11...16, step: 1) { + Slider(value: $positionPrecision, in: 11...18, step: 1) { } minimumValueLabel: { Image(systemName: "minus") } maximumValueLabel: { diff --git a/Meshtastic/Views/Settings/Config/PositionConfig.swift b/Meshtastic/Views/Settings/Config/PositionConfig.swift index 4e940c69..1ba854fa 100644 --- a/Meshtastic/Views/Settings/Config/PositionConfig.swift +++ b/Meshtastic/Views/Settings/Config/PositionConfig.swift @@ -146,8 +146,12 @@ struct PositionConfig: View { .pickerStyle(SegmentedPickerStyle()) .padding(.top, 5) .padding(.bottom, 5) - if gpsMode == 1 { + + + Text("Positions will be provided by your device GPS, if you select disabled or not present you can set a fixed position.") + .foregroundColor(.gray) + .font(.callout) VStack(alignment: .leading) { Picker("Update Interval", selection: $gpsUpdateInterval) { ForEach(GpsUpdateIntervals.allCases) { ui in @@ -163,7 +167,11 @@ struct PositionConfig: View { VStack(alignment: .leading) { Toggle(isOn: $fixedPosition) { Label("Fixed Position", systemImage: "location.square.fill") - Text("If enabled your current phone location and time will be sent to the device and will broadcast over the mesh on the position interval.") + if !(node?.positionConfig?.fixedPosition ?? false) { + Text("Your current location will be set as the fixed position and broadcast over the mesh on the position interval.") + } else { + + } } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) }