Attempting to programming the vivoactive again, this time I am wanting to update some values from Activity. I cannot for the life of me workout why the following section of code does not work.
function onUpdate(dc) {
var activityInfo;
activityInfo = Act.getActivityInfo();
if ( activityInfo != null && activityInfo.elapsedTime != null ) {
dc.drawText( pt2_x, pt2_y, Gfx.FONT_MEDIUM , activityInfo.elapsedTime.toString(), Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
if ( activityInfo != null && activityInfo.elapsedDistance != null ) {
dc.drawText(pt6_x, pt6_y, Gfx.FONT_LARGE , activityInfo.elapsedDistance.toString(), Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
if ( activityInfo != null && activityInfo.currentSpeed != null) {
dc.drawText(pt5_x, pt5_y, Gfx.FONT_LARGE , activityInfo.currentSpeed.toString(), Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
}
The currentSpeed is displayed fine, elapsedTime is always displayed as zero and elapsedDistance is never displayed at all. If I run it in the simulator all fields are updated just fine. The only thing I can be thinking is, I have somehow missed how the Activity works or elapsedTime/elapsedDistance fields don't work when using Act.getActivityInfo() ??
I have used elapsedDistance and elapsedTime in a simpledatafield on the onCompute function and it works fine in there, so I am really at a loss here. Can anyone tell me what I am doing wrong?