How to get training zones (HR and Power) ?

Hello,
I am writing a Datafield and I would like to get the training zones (HR + PWR) which are defined in the setup of the Garmin device.
I did not find anything in the API documentation..; Strange...
Thanks for your help.
Patrick
  • - (Array) getHeartRateZones(sport)

    Returns Array of zone thresholds for the requested sport. The returned array contains zone values as follows:

    min zone 1, max zone 1, max zone 2, max zone 3, max zone 4, max zone 5
    Parameters:
    sport (Number) — The sport that zones are being requested from. Should be a HR_ZONE_SPORT_XXX value.
    Returns:
    (Array) — Array of zone thresholds for the requested sport. The returned array contains zone values as follows:
    min zone 1, max zone 1, max zone 2, max zone 3, max zone 4, max zone 5
    Since:
    1.2.6
  • Thanks.

    Ok for HR !

    Is-there a similar solution for Power ?
  • I can't understand why it is implemented for HR... But not for PWR !!! It-is really missing...
  • getCurrentSport and getHeartRateZones fail on Epix hardware

    - (Array) getHeartRateZones(sport)

    Returns Array of zone thresholds for the requested sport. The returned array contains zone values as follows:

    min zone 1, max zone 1, max zone 2, max zone 3, max zone 4, max zone 5
    Parameters:
    sport (Number) — The sport that zones are being requested from. Should be a HR_ZONE_SPORT_XXX value.
    Returns:
    (Array) — Array of zone thresholds for the requested sport. The returned array contains zone values as follows:
    min zone 1, max zone 1, max zone 2, max zone 3, max zone 4, max zone 5
    Since:
    1.2.6


    Can anyone tell me what I'm missing here? This code:

    function GetUserHeartRateZones() {
    // Returns an array of heart rate zone boundaries from the User Profile
    System.println("Calling 'UserProfile.getProfile().getCurrentSport();'");
    var currentSport = UserProfile.getProfile().getCurrentSport().toNumber();
    System.println("currentSport = " + currentSport.toString());
    var heartRateZones = UserProfile.getProfile().getHeartRateZones(currentSport);
    var indexZone = 0;
    while (indexZone <= 5) {
    System.println("heartRateZones[" + indexZone.toString() + "] = " + heartRateZones[indexZone].toString());
    indexZone += 1;}
    return heartRateZones;}

    Generates this console output running in the Epix simulator:

    Calling 'UserProfile.getProfile().getCurrentSport();'
    currentSport = 0
    heartRateZones[0] = 104
    heartRateZones[1] = 120
    heartRateZones[2] = 136
    heartRateZones[3] = 152
    heartRateZones[4] = 168
    heartRateZones[5] = 185

    But when run on my physical Epix device, I get this instead:

    Calling 'UserProfile.getProfile().getCurrentSport();'
    UnexpectedTypeException: Expected String, given Object

    If I instead hardwire the value for currentSport like this:

    var currentSport = 0;

    Again, it works fine in the Epix simulator, but on the physical device I get this:

    currentSport = 0
    UnexpectedTypeException: Expected String, given Object

    Any idea what I'm doing wrong?
  • Can anyone tell me what I'm missing here? This code:

    function GetUserHeartRateZones() {
    // Returns an array of heart rate zone boundaries from the User Profile
    System.println("Calling 'UserProfile.getProfile().getCurrentSport();'");
    var currentSport = UserProfile.getProfile().getCurrentSport().toNumber();
    System.println("currentSport = " + currentSport.toString());
    var heartRateZones = UserProfile.getProfile().getHeartRateZones(currentSport);
    var indexZone = 0;
    while (indexZone <= 5) {
    System.println("heartRateZones[" + indexZone.toString() + "] = " + heartRateZones[indexZone].toString());
    indexZone += 1;}
    return heartRateZones;}

    Generates this console output running in the Epix simulator:

    Calling 'UserProfile.getProfile().getCurrentSport();'
    currentSport = 0
    heartRateZones[0] = 104
    heartRateZones[1] = 120
    heartRateZones[2] = 136
    heartRateZones[3] = 152
    heartRateZones[4] = 168
    heartRateZones[5] = 185

    But when run on my physical Epix device, I get this instead:

    Calling 'UserProfile.getProfile().getCurrentSport();'
    UnexpectedTypeException: Expected String, given Object

    If I instead hardwire the value for currentSport like this:

    var currentSport = 0;

    Again, it works fine in the Epix simulator, but on the physical device I get this:

    currentSport = 0
    UnexpectedTypeException: Expected String, given Object

    Any idea what I'm doing wrong?


    The Epix I don't believe supports this, the API states it is available in 1.2.6 and forward, the Epix is on 1.2.1.
  • The Epix I don't believe supports this, the API states it is available in 1.2.6 and forward, the Epix is on 1.2.1.


    Arrgh! My mistake - making one of those infamous assumptions without reading carefully! It didn't occur to me that the simulator would support something that wasn't faithful to the corresponding device's capabilities. :-(

    Thanks to you (for reminding me of Garmin's decision to neglect some of most basic functionality that you would reasonably expect to be available in what was not long ago their top-of-the-line device)!

    :-(
  • Former Member
    Former Member over 9 years ago
    The Epix I don't believe supports this, the API states it is available in 1.2.6 and forward, the Epix is on 1.2.1.


    How do you know which version each device is at? Would it help to specify minSdkVersion="1.2.6" in the manifest?
  • How do you know which version each device is at? Would it help to specify minSdkVersion="1.2.6" in the manifest?


    I would suggest using "has" which has been a current topic in the forums and specifying SDK 1.2 in the build properties. I find it best to have a default case and then build around the possible expansion of functionality if they has the right VM version.
  • Former Member
    Former Member over 9 years ago
    If it doesn't support HR zones, I don't want to support it. I suppose I could build for 1.3 and above only.

    Is there a way to find out what version each device is at?