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