gpsrec: Ensure we don't turn GPS off if it was previously on (eg from another app/widget)

pull/513/head
Gordon Williams 2020-06-25 07:55:44 +01:00
parent 30519272cf
commit e859c3d20c
3 changed files with 11 additions and 5 deletions

View File

@ -344,7 +344,7 @@
{ "id": "gpsrec",
"name": "GPS Recorder",
"icon": "app.png",
"version":"0.10",
"version":"0.11",
"interface": "interface.html",
"description": "Application that allows you to record a GPS track. Can run in background",
"tags": "tool,outdoors,gps,widget",

View File

@ -10,4 +10,5 @@
0.09: Change default GPS period to 10 (1 is overkill for most uses and makes things slow)
Added RAM keyword to functions & other tweaks to speed up rendering
Going 'back' from track view now doesn't load again
0.10: Can now graph altitude & speed
0.10: Can now graph altitude & speed
0.11: Ensure we don't turn GPS off if it was previously on (eg from another app/widget)

View File

@ -4,6 +4,7 @@
var fixToggle = false; // toggles once for each reading
var gpsTrack; // file for GPS track
var periodCtr = 0;
var gpsOn = false;
// draw your widget
function draw() {
@ -45,17 +46,21 @@
settings.file |= 0;
Bangle.removeListener('GPS',onGPS);
var gOn = false;
if (settings.recording) {
WIDGETS["gpsrec"].width = 24;
Bangle.on('GPS',onGPS);
Bangle.setGPSPower(1);
Bangle.on('GPS', onGPS);
var n = settings.file.toString(36);
gpsTrack = require("Storage").open(".gpsrc"+n,"a");
gOn = true;
} else {
WIDGETS["gpsrec"].width = 0;
Bangle.setGPSPower(0);
gpsTrack = undefined;
}
if (gOn != gpsOn) {
Bangle.setGPSPower(gOn);
gpsOn = gOn;
}
}
// add the widget
WIDGETS["gpsrec"]={area:"tl",width:24,draw:draw,reload:function() {