I do my first steps with Connect IQ and I try to develop for my Edge 820 a Simple Data field displaying alternatively Altitude and Temperature.
Currently I failed to display temperature (I would like Temperature from Edge's sensor), I try many ways but I think I miss something and I did not find example fo the site) could you help me ?
So please find my (first :-)) code below, Thanks
McEwans
using Toybox.WatchUi as Ui;
using Toybox.System as Sys;
using Toybox.Time as Time;
using Toybox.Sensor as Sensor;
class AltitudeTempView extends Ui.SimpleDataField {
var counter;
function initialize() {
SimpleDataField.initialize();
label = "Temp/Altitude";
counter = 0;}
function compute(info) {
var value_picked = null;
if(counter > 0) {value_picked = info.temperature;}
if(counter > 6) {value_picked = info.altitude;}
counter += 1;
if(counter > 10) {counter = 1;}
return value_picked;}
}