From 85c2a9e938a0801d4bca993eb6fd98289c2539b3 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 24 Feb 2024 22:33:11 -0800 Subject: [PATCH] Hook up the position precision channel settings --- Meshtastic/Helpers/BLEManager.swift | 2 +- .../Nodes/Helpers/Map/NodeMapSwiftUI.swift | 2 +- Meshtastic/Views/Settings/Channels.swift | 38 ++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 045fb762..d80dbd15 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -532,7 +532,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate connectedPeripheral.name = myInfo?.bleName ?? "unknown".localized connectedPeripheral.longName = myInfo?.bleName ?? "unknown".localized } - //tryClearExistingChannels() + tryClearExistingChannels() } // NodeInfo if decodedInfo.nodeInfo.num > 0 {// && !invalidVersion { diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift index a3199d43..62ba5ab9 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift @@ -106,7 +106,7 @@ struct NodeMapSwiftUI: View { let radius : CLLocationDistance = pp?.precisionMeters ?? 0 if radius > 0.0 { MapCircle(center: position.coordinate, radius: radius) - .foregroundStyle(Color(nodeColor).opacity(0.60)) + .foregroundStyle(Color(nodeColor).opacity(0.60)) } } Annotation(position.latest ? node.user?.shortName ?? "?": "", coordinate: position.coordinate) { diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index d09e986f..d8bd3818 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -88,6 +88,20 @@ struct Channels: View { positionPrecision = 0 preciseLocation = false positionsEnabled = false + } else { + positionPrecision = Double(channel.positionPrecision) + if positionPrecision == 32 { + preciseLocation = true + positionsEnabled = true + } else { + preciseLocation = false + } + + if positionPrecision == 0 { + positionsEnabled = false + } else { + positionsEnabled = true + } } isPresentingEditView = true }) { @@ -314,6 +328,28 @@ struct Channels: View { .onChange(of: channelRole) { _ in hasChanges = true } + .onChange(of: preciseLocation) { loc in + if loc { + positionPrecision = 32 + } else { + positionPrecision = 14 + } + hasChanges = true + + } + .onChange(of: positionPrecision) { _ in + hasChanges = true + } + .onChange(of: positionsEnabled) { pe in + if pe { + if positionPrecision == 0 { + positionPrecision = 32 + } + } else { + positionPrecision = 0 + } + hasChanges = true + } .onChange(of: uplink) { _ in hasChanges = true } @@ -385,7 +421,7 @@ struct Channels: View { channelName = "" channelRole = 2 hasChanges = false - _ = bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) + //_ = bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!) } } label: { Label("save", systemImage: "square.and.arrow.down")