Skip to content

Compass view#1504

Merged
garthvh merged 8 commits into
meshtastic:compass_viewfrom
RCGV1:compass-view
Dec 14, 2025
Merged

Compass view#1504
garthvh merged 8 commits into
meshtastic:compass_viewfrom
RCGV1:compass-view

Conversation

@RCGV1

@RCGV1 RCGV1 commented Nov 18, 2025

Copy link
Copy Markdown
Member

What changed?

Added a compass view to help you navigate to a node.

Why did it change?

This enables Meshtastic to be a more useful tool in offgrid scenarios where you need to quickly locate a friend, dog, or other Meshtastic tracker.

How is this tested?

Tested on my iPhone and verified the directions.

Screenshots/Videos (when applicable)

ScreenRecording_11-18-2025.00-24-42_1.MP4
ScreenRecording_11-18-2025.00-25-28_1.MP4

Checklist

  • My code adheres to the project's coding and style guidelines.
  • I have conducted a self-review of my code.
  • I have commented my code, particularly in complex areas.
  • I have verified whether these changes require an update to existing documentation or if new documentation is needed, and created an issue in the docs repo if applicable.
  • I have tested the change to ensure that it works as intended.

@thebentern

Copy link
Copy Markdown
Collaborator

Looks good! Very handy for backpacking and SAR use cases. Can the node indicator match the nodenum color?

@RCGV1

RCGV1 commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

@thebentern Done
IMG_5130
IMG_5131

@jakevis

jakevis commented Dec 1, 2025

Copy link
Copy Markdown

Just wanted to come and give a huge ❤️ for this. We have used Meshtastic for a few years a various festivals now; and "navigate to node" in a compass style is critically needed- and this is amazing. We have been using w3w's and copying locations back and forth- thank you so much! looking forward to it making it into the main release.

@garthvh garthvh changed the base branch from main to 2.7.6 December 10, 2025 06:19
@garthvh garthvh requested a review from Copilot December 10, 2025 06:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a compass view feature to the Meshtastic iOS app, enabling users to navigate to nodes using real-time heading and bearing information. The feature provides visual compass guidance with haptic feedback when aligned with a target waypoint.

Key Changes

  • Introduced a new CompassView component with bearing calculations, distance display, and alignment detection with haptic feedback
  • Enhanced LocationsHandler to support heading updates from the device's magnetometer
  • Integrated compass access points in both node detail screens and position popovers

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
Meshtastic/Views/Helpers/CompassView.swift New compass view implementation with waypoint navigation, bearing calculations, and visual/haptic feedback
Meshtastic/Helpers/LocationsHandler.swift Added heading update methods and magnetometer support to track device orientation
Meshtastic/Views/Nodes/Helpers/NodeDetail.swift Added "Open Compass" button and sheet presentation for compass view
Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift Added compass navigation button with presentation detents and navigation destination
Meshtastic.xcodeproj/project.pbxproj Added CompassView.swift to build phases
Meshtastic.xcworkspace/xcshareddata/swiftpm/Package.resolved Updated package hash
Localizable.xcstrings Added localization entries for compass-related strings and unrelated privacy policy updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Meshtastic/Views/Helpers/CompassView.swift Outdated
Comment thread Meshtastic/Views/Nodes/Helpers/Map/PositionPopover.swift Outdated
Comment on lines +43 to +44
let rawDiff = abs(heading - bearing).truncatingRemainder(dividingBy: 360)
let diff = min(rawDiff, 360 - rawDiff)

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation in this function. Line 43 has extra leading spaces compared to lines 44 and 45.

Suggested change
let rawDiff = abs(heading - bearing).truncatingRemainder(dividingBy: 360)
let diff = min(rawDiff, 360 - rawDiff)
let rawDiff = abs(heading - bearing).truncatingRemainder(dividingBy: 360)
let diff = min(rawDiff, 360 - rawDiff)

Copilot uses AI. Check for mistakes.
Comment thread Meshtastic/Views/Helpers/CompassView.swift Outdated
Comment thread Meshtastic/Views/Helpers/CompassView.swift Outdated
)
// Move waypoint marker outside compass
.onChange(of: locationsHandler.heading) { _, _ in
checkAlignment(bearing: bearing,heading:locationsHandler.heading)

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in function call. Should be checkAlignment(bearing: bearing, heading: locationsHandler.heading) with a space after the comma.

Suggested change
checkAlignment(bearing: bearing,heading:locationsHandler.heading)
checkAlignment(bearing: bearing, heading: locationsHandler.heading)

Copilot uses AI. Check for mistakes.
}
}
.sheet(isPresented: $showingCompassSheet) {
CompassView(waypointLocation: node.latestPosition?.nodeCoordinate ?? nil, waypointName: node.user?.longName ?? nil, color: Color(UIColor(hex: UInt32(node.num))))

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ?? nil is redundant and serves no purpose. If node.latestPosition?.nodeCoordinate is nil, it will already be nil without the nil-coalescing operator. The same applies to node.user?.longName ?? nil. Simply remove the ?? nil parts.

Suggested change
CompassView(waypointLocation: node.latestPosition?.nodeCoordinate ?? nil, waypointName: node.user?.longName ?? nil, color: Color(UIColor(hex: UInt32(node.num))))
CompassView(waypointLocation: node.latestPosition?.nodeCoordinate, waypointName: node.user?.longName, color: Color(UIColor(hex: UInt32(node.num))))

Copilot uses AI. Check for mistakes.
Comment on lines +137 to +139
self.manager.headingFilter = 1 // Update heading when it changes by 1 degree
self.manager.headingOrientation = .portrait // Adjust based on device orientation
}

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation. The body of the if statement on lines 137-138 has an extra level of indentation (two tabs instead of one). This should be aligned with the rest of the code.

Suggested change
self.manager.headingFilter = 1 // Update heading when it changes by 1 degree
self.manager.headingOrientation = .portrait // Adjust based on device orientation
}
self.manager.headingFilter = 1 // Update heading when it changes by 1 degree
self.manager.headingOrientation = .portrait // Adjust based on device orientation
}

Copilot uses AI. Check for mistakes.
}

// Trigger a vibration if aligned with waypoint
private func checkAlignment(bearing: Double,heading: Double) {

Copilot AI Dec 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in function parameter list. Should be checkAlignment(bearing: Double, heading: Double) with a space after the comma.

Suggested change
private func checkAlignment(bearing: Double,heading: Double) {
private func checkAlignment(bearing: Double, heading: Double) {

Copilot uses AI. Check for mistakes.
Comment thread Meshtastic/Views/Helpers/CompassView.swift Outdated
RCGV1 and others added 5 commits December 9, 2025 22:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@garthvh garthvh changed the base branch from 2.7.6 to compass_view December 14, 2025 20:52
@garthvh garthvh merged commit 3e11321 into meshtastic:compass_view Dec 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants