Skip to content

Compass improvements/refactoring#10166

Merged
thebentern merged 24 commits intodevelopfrom
Compass-calibration
Apr 18, 2026
Merged

Compass improvements/refactoring#10166
thebentern merged 24 commits intodevelopfrom
Compass-calibration

Conversation

@HarukiToreda
Copy link
Copy Markdown
Contributor

@HarukiToreda HarukiToreda commented Apr 15, 2026

Summary
This PR improves compass behavior and reliability across BaseUI compasses. Address this PR #9928

Changes

  • Fixes issue with calibration looping forever and never completing.
  • Compass calibration is now saved and loaded automatically, so it survives reboot.
  • Calibration screen now gives more detailed instructions on how to perform calibration.
  • Fixes issue with calibration looping forever and never completing.
  • Increased redraw fps to 20 to make heading movement smoth on live data from compass.
  • Compass calibration flow was cleaned up and shared across supported sensors.
  • Compass heading updates are smoother and less jumpy.
  • Compass heading is more user friendly:
    -- "no heading" is shown right after first lock until there is enough movement(2 gps cords)
    -- GPS-based heading only appears after real movement (~10m/30ft), not immediately at first lock.
    -- heading clears after staying still for a while, based on GPS/smart position timing
    -- Compass screens now show clearer fallback states like "No Fix" and "No Heading" instead of misleading direction arrow that was untrustworthy .
    -- Compass math/logic was unified so node, waypoint, and location screens behave consistently.
    -- Small flash size cleanup in the new compass code.

Result
Compass data is more trustworthy, calibration is easier for users, and compass related screens behave more consistently.

T114 build with this PR
RAM: [==== ] 44.4% (used 110436 bytes from 248832 bytes)
Flash: [========= ] 88.6% (used 722068 bytes from 815104 bytes)

T114 build with Develop
RAM: [==== ] 44.4% (used 110436 bytes from 248832 bytes)
Flash: [========= ] 88.4% (used 720292 bytes from 815104 bytes)

20260414_233431.mp4

@HarukiToreda HarukiToreda requested a review from jp-bennett April 15, 2026 04:15
@HarukiToreda HarukiToreda self-assigned this Apr 15, 2026
@HarukiToreda HarukiToreda added enhancement New feature or request baseui Issues directly related to BaseUI bugfix Pull request that fixes bugs gps GPS subsystem cleanup Code cleanup or refactor labels Apr 15, 2026
@github-actions github-actions Bot added the needs-review Needs human review label Apr 15, 2026
@HarukiToreda HarukiToreda marked this pull request as draft April 15, 2026 05:00
@HarukiToreda HarukiToreda marked this pull request as ready for review April 15, 2026 06:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 refactors and improves compass behavior across UI screens by unifying heading/bearing math, improving calibration flow, persisting magnetometer calibration, and increasing UI refresh rate when compass data is active (addressing #9928’s “misleading compass” concerns).

Changes:

  • Persist magnetometer calibration (save/load) and unify calibration flow across supported motion sensors.
  • Unify heading/bearing computation via CompassRenderer helpers and improve UI fallback states (“No Fix” / “No Heading”).
  • Smooth compass heading updates and raise target FPS (to 20) for compass-related frames.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/motion/MotionSensor.h Faster sensor polling; adds shared calibration persistence + helper utilities.
src/motion/MotionSensor.cpp Implements calibration record save/load and improved calibration UI frame text/layout.
src/motion/ICM20948Sensor.h / .cpp Loads/saves calibration and uses shared calibration/orientation helpers.
src/motion/BMX160Sensor.h / .cpp Loads/saves calibration and uses shared calibration/orientation helpers.
src/motion/BMM150Sensor.cpp Uses shared compass orientation helper; removes unused IRQ flag.
src/graphics/draw/CompassRenderer.h / .cpp Introduces shared heading/bearing helpers used across screens.
src/graphics/Screen.h / .cpp Adds smoothed setHeading(float); improves GPS-estimated heading staleness handling; raises FPS on compass frames.
src/graphics/draw/UIRenderer.cpp Uses shared heading helpers and displays “No Fix/No Heading” status in compass areas.
src/modules/WaypointModule.cpp Updates waypoint compass rendering/fallback logic and uses shared heading helpers.
src/graphics/draw/NodeListRenderer.h / .cpp Uses shared heading helpers and shows unknown-bearing markers when heading/fix is missing.

Comment thread src/graphics/Screen.cpp
Comment thread src/modules/WaypointModule.cpp Outdated
Comment thread src/motion/MotionSensor.cpp Outdated
@HarukiToreda HarukiToreda linked an issue Apr 18, 2026 that may be closed by this pull request
3 tasks
@thebentern thebentern merged commit aab4cd0 into develop Apr 18, 2026
78 checks passed
@HarukiToreda HarukiToreda deleted the Compass-calibration branch April 19, 2026 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

baseui Issues directly related to BaseUI bugfix Pull request that fixes bugs cleanup Code cleanup or refactor enhancement New feature or request gps GPS subsystem needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Compass without magnetometer is misleading and potentially dangerous

5 participants