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
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.
How do you know which version each device is at? Would it help to specify minSdkVersion="1.2.6" in the manifest?