Changed setInterval() to Bangle.on(GPS)
This commit is contained in:
parent
a6df06345b
commit
ac46c10ccf
@ -1,6 +1,5 @@
|
||||
(() => {
|
||||
let STOR = require("Storage");
|
||||
let updateInterval;
|
||||
let lastSpeed;
|
||||
|
||||
function drawFace() {
|
||||
@ -46,9 +45,8 @@ function drawFace() {
|
||||
}
|
||||
|
||||
|
||||
updateInterval = setInterval(
|
||||
() => {
|
||||
var gps_fix = Bangle.getGPSFix();
|
||||
Bangle.on("GPS",
|
||||
(gps_fix) => {
|
||||
var speed = round(gps_fix.speed, 1);
|
||||
if(speed<3.4) speed="0.0";
|
||||
if(Number(speed)>maxSpeed) maxSpeed = speed;
|
||||
@ -84,14 +82,13 @@ function drawFace() {
|
||||
naNShown = true;
|
||||
}
|
||||
lastSpeed = speed; // set last speed var for next loop
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
|
||||
function stop() {
|
||||
g.clear();
|
||||
Bangle.removeAllListeners();
|
||||
Bangle.setGPSPower(false);
|
||||
print("[DEBUG] updateInterval=" + updateInterval);
|
||||
clearInterval(updateInterval);
|
||||
}
|
||||
|
||||
return { drawFace:drawFace, stop:stop };
|
||||
|
Loading…
Reference in New Issue
Block a user