Newbie problems with first project - 3 part data field

I have been playing with the SDK and built a 3 item datafield to display HR (data1), Distance (data2) and Cadence (data3). I based it on the 0.2.4 ComplexDataField sample.

Heart rate works great - updates consistently, in step with the Garmin Heart Rate field

For distance, I just want full kms (similar to 1km auto-laps) - tried int(info.elapsedDistance). This doesn't seem to advance from 0. Maybe a scaling factor?

Cadence is where I am having a strange problem. It only updates sporadically and holds the value for minutes at a time, then randomly zeroes or changes. This is despite the fact that the stock Garmin Cadence field is being constantly updated. My field is not keeping step in reflecting those changes. I think info.currentCadence is the correct - just not sure why it isn't changing regularly like the Garmin field does.

Can you please take a quick look and see if I'm missing something fundamental?

I am using a vivoactive on FW2.80

function compute(info)
{
var info = Act.getActivityInfo();
//Get data1 if valid
if( info.currentHeartRate != null )
{
data1 = info.currentHeartRate;
}

//Get data2 if valid
if( info.elapsedDistance != null )
{
data2 = int(info.elapsedDistance);
}

//Get data3 if valid
if( info.currentCadence != null )
{
data3 = info.currentCadence;
}
}
  • For distance, I just want full kms (similar to 1km auto-laps) - tried int(info.elapsedDistance). This doesn't seem to advance from 0. Maybe a scaling factor?

    info.elapsedDistance is measured in meters. You need to convert that to kilometers (divide by 1000, or multiply by 0.001) if you want to display kilometers.

    Cadence is where I am having a strange problem. It only updates sporadically and holds the value for minutes at a time, then randomly zeroes or changes. This is despite the fact that the stock Garmin Cadence field is being constantly updated. My field is not keeping step in reflecting those changes.

    I'm not sure what is going on, but it help to eliminate calculate() and to add the necessary code to onUpdate(). You can fetch the current activity info via Toybox.Activity.getActivityInfo().