Widget: Compass



https://apps.garmin.com/en-US/apps/7115691d-7456-43ef-92bd-92a5885f16c7

A simple compass widget that looks eerily similar to the built-in compass on the Fenix3. On devices with a magnetic compass, the compass will report your heading (the direction you are facing). For devices without device support, the compass will display your heading (the direction you are travelling).

*Note*: I understand there is a 10 second timeout on the vivoactive, and this makes the widget less useful than I'd like. I've created an app version that is available here. https://apps.garmin.com/en-US/apps/663c7106-883c-4fbc-9a89-e01d9e9983ac

Revision History

1.0.5
* Center text displayed when not able to acquire a compass heading or GPS position.

1.0.4
* Removed debug tracing.

1.0.3
* Resolve issue with compass heading not being displayed correctly on the vivoactive.

1.0.1
* Resolve issue with serialization of application properties.

1.0.0
* Initial Revision
  • I have a review that indicates the widget does not work on a vivoactive. I _believe_ that the issue is that the device doesn't have a magnetic compass, so it only reports a heading based on the direction you are moving.

    Could someone with a vivoactive verify that the app does (or does not) work? If it does not seem to update correctly when standing still, does it seem to work correctly when you are moving in a given direction?
  • Haven't tried it, but I know there is no compass in the vivoactive, and as another note, on the vivoactive, a widget reverts to the watchface after about 10 seconds, not a minute as with other device. And on the va, I think you'd have to fire up GPS inside the widget.
  • Yeah, I'm just looking for a victim to verify that it does indeed not work before I go in and make a bunch of unnecessary changes.

    Additionally, I don't see anything to indicate the existence of a magentometer, so I have nothing to use to decide to turn the GPS on or not. Assuming, of course, that turning GPS on and prompting the user to move is sufficient to get it working.
  • Former Member
    Former Member over 10 years ago
    Products without a compass should return a sensor info object with null heading if GPS is not enabled. You should be able to trigger enabling GPS off of that condition.
  • Interesting. My code has this...

    function onUpdate(dc) {

    var info = Sensor.getInfo();
    if (info == null || info.heading == null) {
    dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
    dc.clear();

    dc.drawText(_cx, _cy, Gfx.FONT_LARGE, "NO HEADING",
    Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);

    }
    else {


    The user indicates

    This doesn't appear to work on the Vivoactive. It always shows East


    Given what you've said and the above code, I'd expect to see the string NO HEADING to be displayed. Is it possible he is using bad firmware?
  • I've worked around this using the resource system. I added this to the resource files for all devices except the vivoactive.

    <strings>
    <string id="Magnetometer" />
    </strings>


    Then I use this code to pick the implementation...

    // pick a compass implementation
    if (Rez.Strings has :Magnetometer) {
    _impl = new MagneticCompassImpl();
    }
    else {
    _impl = new PositionCompassImpl();
    }


    It is a hack, but it seems to work.
  • I have manual screen backlight on my 920xt. When using the widget light shuts off anyway (as it do, when in watchface mode). Can you prevent it? So if I switched it on, it would stay on until I quit the widget.
    And thank you, again, for such a great widget!
  • Travis. I threw together a simple widget that simply uses Position to get the current lat/lon and display it. On the vivoactive, in clear sky, maybe 1/3 of the time it can't get and display the info before the 10 sec revert timeout on the vivoactive. YMMV.
  • What 10 second revert timeout? Your post here indicates that the widget to watch face revert timeout was 60 seconds. Am I missing something?
  • It's longer on other devices (60 sec). on the VA, it's 10 sec. There is talk about changing it on the VA, but nothing is being done yet as far as I know. I said changing it was being considered, but it's still 10 sec!

    see the case here with using a makeJson in a widget on the VA. I point out that it's 10 sec on the VA.

    https://forums.garmin.com/showthread.php?222154-How-to-prevent-a-widget-to-revert-to-the-watch-page-after-59-seconds