Skip to content

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

Description

@isgulkov

Category

Other

Hardware

LILYGO T-Beam v1.2

Is this bug report about any UI component firmware like InkHUD or Meshtatic UI (MUI)?

  • Meshtastic UI aka MUI colorTFT
  • InkHUD ePaper
  • OLED slide UI on any display

Firmware Version

2.7.20

Description

Summary

On the "Position" screen (with the GPS coords) there's a compass. Everyone knows what a compass is.

Unfortunanely, on devices without a magnetometer, the compass, instead of pointing north, point wherever... It's in the approximate direction of last 10m user's travel, or something... Already questionable utility, but...

I’s still drawn like a normal compass, it even has an “N” at the arrow's tip! A user can reasonably assume it shows magnetic north — I assumed that for a while (on a T-Beam 1.2) before I looked at the code!

And I don't need to elaborate what can happen to a person if they try to navigate using a compass and their compass isn't a a compass. You don't need to be very far from civilization to get lost and die from exposure — 5–10 km is enough.

Moreover, it shows a stale or meaningless value when stationary. And, if we're in the full nitpick mode, on the first call, it displays garbage from uninitialized memory...

Here's the cancer, it's around src/graphics/Screen.cpp:271:

float Screen::estimatedHeading(double lat, double lon)
{
    static double oldLat, oldLon;
    static float b;

    if (oldLat == 0) {
        // just prepare for next time
        oldLat = lat;
        oldLon = lon;

        return b;
    }

    float d = GeoCoord::latLongToMeter(oldLat, oldLon, lat, lon);
    if (d < 10) // haven't moved enough, just keep current bearing
        return b;

    b = GeoCoord::bearing(oldLat, oldLon, lat, lon) * RAD_TO_DEG;
    oldLat = lat;
    oldLon = lon;

    return b;
}

Suggested fix

Don’t draw a compass at all when there’s no magnetometer.

I'll leave it to the developers to think what to display instead of the fake "compass" on no-magnetometer devices, but if I was in their shoes, I'd just remove this "fake compass" stuff, ship that with the next version, and then discuss what to display there.

(by the way, do you know what the GPS screen lacks? HDOP!)

Relevant log output

Metadata

Metadata

Assignees

Labels

baseuiIssues directly related to BaseUIbugSomething isn't workingfirst-contributiongpsGPS subsystem

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions