How can I do a fit contributions simple switch on settings, is this ok??
using Toybox.FitContributor;
using Toybox.WatchUi;
class BananasEarnedView extends WatchUi.SimpleDataField
{
var bananasEarnedField = null;
var totalBananas = 0.0;
const CALORIES_PER_BANANA = 105.0;
const BANANAS_FIELD_ID = 0;
function initialize() {
SimpleDataField.initialize();
// Create the custom FIT data field we want to record.
if (fitCont = 0) {
bananasEarnedField = createField(
"bananas_earned",
BANANAS_FIELD_ID,
FitContributor.DATA_TYPE_FLOAT,
{:mesgType=>Fit.MESG_TYPE_RECORD, :units=>"B"}
);
}
function onTimerStop();
if (fitCont = 0) {
bananasEarnedField.setData(0.0);
}
}
function compute(info) {
if (info != null && info.calories != null) {
// Calculate and set data to be written to the Field
totalBananas = (info.calories / CALORIES_PER_BANANA).toFloat();
bananasEarnedField.setData(totalBananas);
}
// Display the data on the screen of the device
return totalBananas;
}
}