From 8970464fecdbd5ab4aba8d52725c8d579ffd5f4a Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 5 Feb 2023 18:36:35 -0800 Subject: [PATCH] =?UTF-8?q?Speed=20=F0=9F=8F=8E=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Meshtastic/Helpers/BLEManager.swift | 8 ++++---- Meshtastic/Helpers/LocationHelper.swift | 4 ++-- Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift | 16 +++++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 746429ca..acd68368 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -796,15 +796,15 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { positionPacket.timestamp = UInt32(LocationHelper.currentTimestamp.timeIntervalSince1970) positionPacket.altitude = Int32(LocationHelper.currentAltitude) positionPacket.satsInView = UInt32(LocationHelper.satsInView) - // Get Errors without some speed - if LocationHelper.currentSpeed >= 5 { - + if LocationHelper.currentSpeed >= 0 { positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed) + } + if LocationHelper.currentHeading >= 0 { positionPacket.groundTrack = UInt32(LocationHelper.currentHeading) } var meshPacket = MeshPacket() meshPacket.to = UInt32(destNum) - meshPacket.from = 0 // Send 0 as from from phone to device to avoid warning about client trying to set node num + meshPacket.from = UInt32(fromNodeNum) var dataMessage = DataMessage() dataMessage.payload = try! positionPacket.serializedData() diff --git a/Meshtastic/Helpers/LocationHelper.swift b/Meshtastic/Helpers/LocationHelper.swift index 2d1c7a85..df0a19fd 100644 --- a/Meshtastic/Helpers/LocationHelper.swift +++ b/Meshtastic/Helpers/LocationHelper.swift @@ -36,10 +36,10 @@ class LocationHelper: NSObject, ObservableObject { static var currentHeading: CLLocationDirection { - guard let speed = shared.locationManager.location?.course else { + guard let heading = shared.locationManager.location?.course else { return DefaultHeading } - return speed + return heading } static var currentTimestamp: Date { diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index a2104044..3da58087 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -134,21 +134,27 @@ struct MapViewSwiftUI: UIViewRepresentable { subtitle.text! += "Altitude: \(distanceFormatter.string(fromDistance: Double(positionAnnotation.altitude))) \n" if positionAnnotation.nodePosition?.metadata != nil { let pf = PositionFlags(rawValue: Int(positionAnnotation.nodePosition?.metadata?.positionFlags ?? 3)) - if pf.contains(.Satsinview) { subtitle.text! += "Sats in view: \(String(positionAnnotation.satsInView)) \n" - } else if pf.contains(.Speed) { + } + if pf.contains(.SeqNo) { + subtitle.text! += "Sequence: \(String(positionAnnotation.seqNo)) \n" + } + if pf.contains(.Speed) { let formatter = MeasurementFormatter() formatter.locale = Locale.current subtitle.text! += "Speed: \(formatter.string(from: Measurement(value: Double(positionAnnotation.speed), unit: UnitSpeed.kilometersPerHour))) \n" } + if pf.contains(.Heading) { + subtitle.text! += "Heading: \(String(positionAnnotation.heading)) \n" + } } subtitle.text! += positionAnnotation.time?.formatted() ?? "Unknown \n" subtitle.numberOfLines = 0 annotationView.detailCalloutAccessoryView = subtitle - //let detailsIcon = UIButton(type: .detailDisclosure) - //detailsIcon.setImage(UIImage(systemName: "info.square"), for: .normal) - //annotationView.rightCalloutAccessoryView = detailsIcon + let detailsIcon = UIButton(type: .detailDisclosure) + detailsIcon.setImage(UIImage(systemName: "info.square"), for: .normal) + annotationView.rightCalloutAccessoryView = detailsIcon return annotationView case let waypointAnnotation as WaypointEntity: let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "waypoint") as? MKMarkerAnnotationView ?? MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: "Waypoint")