Hi
I am getting the temp value in my datafield with following code:
MA.mc
(:background)
class MA extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
function getInitialView() {
if(Toybox.System has :ServiceDelegate) {
Background.registerForTemporalEvent(new Time.Duration(60*5));
}
return [ new MVBase() ];
}
function onBackgroundData(data) {
fTemp = bIsImperial ? (data*9.0/5.0+32) : data;
}
function getServiceDelegate(){
return [new BG()];
}
function onStop(state) {
if(!inBackground) {
Background.deleteTemporalEvent();
}
}
}
BG.mc
(:background)
class BG extends Toybox.System.ServiceDelegate {
function initialize() {
System.ServiceDelegate.initialize();
inBackground=true;
}
function onTemporalEvent() {
var info = Sensor.getInfo();
Background.exit(info has :temperature ? info.temperature : -999.0);
}
}
I am reading the fTemp value in my datafield.
The problem I have is, that the battery drain increases when my activity is started with this datafield and the battery drain continues also when activity is finished.
Is there anything I forgot to destroy/close ???
One more question I have: Is it possible to read the temperature more frequent than every 5mins ?
thanks
regards
Erich