import Toybox.Activity;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.WatchUi;
using Toybox.AntPlus;
class *************** extends WatchUi.DataField {
var gros = null;
var big = null;
var info = null;
function initialize() {
DataField.initialize();
}
// Set your layout here. Anytime the size of obscurity of
// the draw context is changed this will be called.
function onLayout(dc as Dc) as Void {
gros = WatchUi.loadResource(Rez.Fonts.gros);
big = WatchUi.loadResource(Rez.Fonts.big);
info = WatchUi.loadResource(Rez.Fonts.info);
View.setLayout(Rez.Layouts.MainLayout(dc));
}
// Display the value you computed here. This will be called
// once a second when the data field is visible.
function onUpdate(dc as Dc) as Void {
setpma3sdisplay();
setcadencedisplay();
setbpmdisplay();
setkmhdisplay();
//settimedisplay();
View.onUpdate(dc);
}
function setpma3sdisplay() {
var pma = Activity.getActivityInfo().currentPower;
var pmaLabel = View.findDrawableById("pma3s") as WatchUi.Text;
if (pma == null) {
pmaLabel.setText("--");
} else {
pmaLabel.setText(pma + "");
} WatchUi.requestUpdate();
}
function setbpmdisplay() {
var bpm = Activity.getActivityInfo().currentHeartRate;
var bpmLabel = View.findDrawableById("bpm") as WatchUi.Text;
if (bpm == null) {
bpmLabel.setText("--");
} else {
bpmLabel.setText(bpm + "");
} WatchUi.requestUpdate();
}
function setkmhdisplay() {
var mh = Activity.getActivityInfo().currentSpeed;
var kmhLabel = View.findDrawableById("kmh") as WatchUi.Text;
if (mh == null) {
kmhLabel.setText("--");
} else {
var kmh = mh * 3.6; // Convertit la vitesse en kilomètres par heure
kmhLabel.setText(kmh.format("%.1f")); // Affiche la valeur en kilomètres par heure avec une décimale
}
WatchUi.requestUpdate();
}
function setcadencedisplay() {
var cadenceb = Activity.getActivityInfo().currentCadence;
var cadenceLabel = View.findDrawableById("cadence") as WatchUi.Text;
if (cadenceb == null) {
cadenceLabel.setText("--");
} else {
var cadence = cadenceb / 2;
cadenceLabel.setText(cadence.toString() + "");
} WatchUi.requestUpdate();
}
}