I'm developing a datafield for Edge 520. I would like to compute the average of a info quantity over a lap.
I'm using the funcion onTimerLap() to identity the time when a lap is created. I could manage to make the callback work (both on simulator and edge).
But It looks to me onTimerLap() does not work when using a workout file.
Below you find small datafiled for laps counting.
When I use it without workout file, it work correctly.
When I use a workout file, it give a value of 3 laps when I start the activity and then it doesn't count neither of laps nor autolap.
Has anybody succesfully used ontimerlap() with a workout file?
using Toybox.WatchUi as Ui;
class Lap_counterView extends Ui.SimpleDataField {
var lap = 0;
// Set the label of the data field here.
function initialize() {
SimpleDataField.initialize();
label = "Lap counter";
}
function onTimerLap()
{
lap += 1;
}
// The given info object contains all the current workout
// information. Calculate a value and return it in this method.
function compute(info) {
// See Activity.Info in the documentation for available information.
return lap;
}
}