Fix GPS apps if time not set in GPS (fix #110)

master
Gordon Williams 2020-03-04 15:04:21 +00:00
parent 107d8ef7e0
commit b93c094340
6 changed files with 48 additions and 45 deletions

View File

@ -2,7 +2,7 @@
{ "id": "boot", { "id": "boot",
"name": "Bootloader", "name": "Bootloader",
"icon": "bootloader.png", "icon": "bootloader.png",
"version":"0.08", "version":"0.09",
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings", "description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
"tags": "tool,system", "tags": "tool,system",
"type":"bootloader", "type":"bootloader",
@ -638,7 +638,7 @@
"id": "gpsinfo", "id": "gpsinfo",
"name": "GPS Info", "name": "GPS Info",
"icon": "gps-info.png", "icon": "gps-info.png",
"version":"0.01", "version":"0.02",
"description": "An application that displays information about altitude, lat/lon, satellites and time", "description": "An application that displays information about altitude, lat/lon, satellites and time",
"tags": "gps", "tags": "gps",
"type": "app", "type": "app",
@ -753,6 +753,7 @@
{ "id": "flagrse", { "id": "flagrse",
"name": "Espruino Flag Raiser", "name": "Espruino Flag Raiser",
"icon": "app.png", "icon": "app.png",
"version":"0.01",
"description": "App to send a command to another Espruino to cause it to raise a flag", "description": "App to send a command to another Espruino to cause it to raise a flag",
"tags": "", "tags": "",
"storage": [ "storage": [

View File

@ -5,3 +5,4 @@
0.06: Disable GPS time log messages, add (default=1) setting to hide log messages 0.06: Disable GPS time log messages, add (default=1) setting to hide log messages
0.07: Fix issues with alarm scheduling 0.07: Fix issues with alarm scheduling
0.08: Fix issues if BLE=off, 'Make Connectable' is chosen, and the loader resets Bangle.js (fix #108) 0.08: Fix issues if BLE=off, 'Make Connectable' is chosen, and the loader resets Bangle.js (fix #108)
0.09: Only check GPS for time after a fresh boot

View File

@ -26,7 +26,6 @@ if (!s.timeout) Bangle.setLCDPower(1);
E.setTimeZone(s.timezone); E.setTimeZone(s.timezone);
delete s; delete s;
// check for alarms // check for alarms
function checkAlarm() {
var alarms = require('Storage').readJSON('alarm.json',1)||[]; var alarms = require('Storage').readJSON('alarm.json',1)||[];
var time = new Date(); var time = new Date();
var active = alarms.filter(a=>a.on&&(a.last!=time.getDate())); var active = alarms.filter(a=>a.on&&(a.last!=time.getDate()));
@ -48,22 +47,3 @@ function checkAlarm() {
},t); },t);
} }
} }
}
// check to see if our clock is wrong - if it is use GPS time
if ((new Date()).getFullYear()==1970) {
//console.log("Searching for GPS time");
Bangle.on('GPS',function cb(g) {
Bangle.setGPSPower(0);
Bangle.removeListener("GPS",cb);
if (!g.time || (g.time.getFullYear()<2000) ||
(g.time.getFullYear()==2250)) {
//console.log("GPS receiver's time not set");
return;
}
setTime(g.time.getTime()/1000);
//console.log("GPS time",g.time.toString());
checkAlarm();
});
Bangle.setGPSPower(1);
} else checkAlarm();
delete checkAlarm;

View File

@ -12,8 +12,27 @@ if (!settings.welcomed && require("Storage").read("welcome.js")!==undefined) {
clockApp = require("Storage").read(clockApps[0].src); clockApp = require("Storage").read(clockApps[0].src);
delete clockApps; delete clockApps;
} }
if (clockApp) eval(clockApp); if (!clockApp) clockApp='E.showMessage("No Clock Found")';
else E.showMessage("No Clock Found"); delete settings;
// check to see if our clock is wrong - if it is use GPS time
if ((new Date()).getFullYear()==1970) {
E.showMessage("Searching for\nGPS time");
Bangle.on('GPS',function cb(g) {
Bangle.setGPSPower(0);
Bangle.removeListener("GPS",cb);
if (!g.time || (g.time.getFullYear()<2000) ||
(g.time.getFullYear()==2250)) {
// GPS receiver's time not set - just boot clock anyway
eval(clockApp);delete clockApp;
return;
}
// We have a GPS time. Set time and reboot (to load alarms properly)
setTime(g.time.getTime()/1000);
load();
});
Bangle.setGPSPower(1);
} else {
eval(clockApp);
delete clockApp; delete clockApp;
} }
delete settings; }

1
apps/gpsinfo/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.02: Ensure screen doesn't display garbage at startup

View File

@ -2,6 +2,7 @@ var img = require("heatshrink").decompress(atob("mEwghC/AH4AKg9wC6t3u4uVC6wWBI6t
Bangle.setGPSPower(1); Bangle.setGPSPower(1);
Bangle.setLCDMode("doublebuffered"); Bangle.setLCDMode("doublebuffered");
E.showMessage("Loading..."); // avoid showing rubbish on screen
var lastFix = { var lastFix = {
fix: 0, fix: 0,