0

A real noob question here but I am trying to write my first ever Custom data field for my Garmin Edge 520. All that I would like to do is add up the time in Zone 3 + Zone 4 + Zone 5 and display it in a simple data field.

I'm sure that there's a simple solution but I'm looking all over and I can't see it. From the API documentation at Connect IQ API Docs under Toybox::UserProfile I can getHeartRateZones and maybe use that info to try to calculate it?

Is there a simple API call to get the time in zone x?

ShaunP
  • 463
  • 1
  • 5
  • 20

1 Answers1

1

I also think that this functionality is not directly provided out of the box through the API.

However, you could write your own ActivityTracker based on the "ActivityTracker" sample in the Connect IQ API Docs. Unfortunately, that essentially means you would have to duplicate the logic of the display you currently see just to add the three fields.

You'd call Toybox.Activity.getActivityInfo() for obtaining the current heart rate at, say, a 1 second intervall (the ActivityTracker example shows you how to implement a 1 second callback), determine in which zone the heart rate is, and increment a counter for that zone. Then you add up the three zones and display that as well.

-cfs

  • Thanks, that fits with what I thought. The documentation about DataField https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/WatchUi/DataField.html shows that it automatically provides Activity.Info once per second via the compute() method. I just set up a counter and each time the compute() method executes I add 1 to the counter and thus have the number of seconds that it is running. – ShaunP Nov 26 '18 at 11:21