Fenix 5x and sunrise/sunset - here's how to do it!

The f5x HW is different with a few things, and one is how a watch face can get lat/lon for sunrise/sunset calculation.
If you have "Contact Developer" messages about your watchfaces and sunrise/sunset, here's something you can reference:

https://forums.garmin.com/showthread.php?376023-quot-HandsFive-quot-Watch-Face-Issues&p=984097#post984097

I explain in the post about what's going on with Activity.info and currentLocation on the f5x, and how to make your watch face run there and display the rise and set.

The key here, is once you have a lat/lon, be sure to save it in the object store so your watchface will have it in the future if a new one isn't available!

Oh, another thing. For things like heart rate, the 3.21 beta or above FW (3.30 is the current production FW) fixes that one!
  • Yes, using the latitude and longitude will do. Thanks!
  • To get the location in a watchface, you don't need positioning. You do something like

    var curLoc=Activity.getActivityInfo[].currentLocation;
    var degs=[null,null];
    if[curLoc! =null] {
    degs=curLoc.toDegrees[];
    }

    then degs[0] is null or lat
    deg[1] is null or lon.
    [] where needed to post
  • To get the location in a watchface, you don't need positioning.


    To clarify, I meant that to run his code as given (which tried to create a new Position), you would need the Positioning permission. To be fair, to do what he wants (get/save lat/lon to calculate sunrise/sunset), you don't need to create a new Position.

    Sorry for being unclear (and for sort of ignoring the intent of the question).

    Yes, using the latitude and longitude will do. Thanks!

    No worries!
  • For others and future references. I've attached the solution that seems to work for me.

    Thanks guys :)
  • Looks like what you are doing should work! Just a note, that this whole thread started back when it was really hard for a watchface to get a valid Activity.Info.currentLocation in an earlier version of firmware for the Fenix 5x :)
  • I'm trying to fix a problem reported by a user where turning the bluetooth off/on make my watch face display an empty sunset/sunrise time "--". He reported that if was working fine for "NoFrills" :)
  • I'm trying to fix a problem reported by a user where turning the bluetooth off/on make my watch face display an empty sunset/sunrise time "--". He reported that if was working fine for "NoFrills" :)


    You weren't using the ObjectStore. :) Hermo (NoFrills) was doing apps back in the CIQ 1.1.x days when the ObjectStore was a bit more mainstream. (to me, there is a clear difference between the Object Store and a Settings property - different files and all, as well as how often they are written to Mass Store. But I don't think it's as clear to some since app settings came about!)
  • Hm, I did a watchface which I will enhance by sunrise/set information now. I thought, it would be possible to check the actual location by the following code, using a default value if no GPS lock is given. In the simulator it looked promissing, but on my watch I get a location which is not my actual position. Please give me a hint what's wrong here...



  • No code is showing. But the basics are you use Activity.Info.currentLocation if it's not null. In that case you also save the location away in the object store, so it can be used if it is null in the future. (anytime it's non-null I save it off, so the saved location is the most recent)

    How different is the location you're seeing from your actual location? How (in what form) are you saving your location in the ObectStore?