I am having my first stab at programming ready for when I get a new garmin. I want to create a data field which shows the estimated finish time for a set distance such as 5km, 10km, half marathon and full marathon based on average speed. So far I have created it for 10km, and the total time for 10km is shown as 69.50 instead of 01:09:30 please can you show me how I would do this:confused:. The code so far is:
using Toybox.WatchUi as Ui;
class testdatafieldView extends Ui.SimpleDataField {
//! Set the label of the data field here.
function initialize() {
label = "10km time";
}
//! 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.
var tenkmtimesecs = null;
var tenkmtimemins = null;
var distanceleft = null;
var timeleftsecs = null;
var timeleftmins = null;
// if( info.elapsedDistance <= 10000 )
// {
// Find out how much distance there is to go:
distanceleft = (10000 - info.elapsedDistance);
// Take the distance left and divide by the average speed:
timeleftsecs = (distanceleft / info.averageSpeed);
// convert from seconds to minutes
timeleftmins = (timeleftsecs / 60 );
// Add the timeleft in seconds to the elsapsed time in milliseconds
tenkmtimesecs = ((info.elapsedTime / 1000) + timeleftsecs);
// Convert tenkmtime from seconds to minutes
tenkmtimemins = (tenkmtimesecs / 60 );
// }
// return distanceleft;
//return pace;
return tenkmtimemins;
}
}
Once I have worked it out once I then want to create a view or widget of the four data fields on one screen but I think I am a while away from doing that. I also need to work out when distance reaches 10km to hold that time.
Any help appreciated.:cool: