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",
"name": "Bootloader",
"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",
"tags": "tool,system",
"type":"bootloader",
@ -638,7 +638,7 @@
"id": "gpsinfo",
"name": "GPS Info",
"icon": "gps-info.png",
"version":"0.01",
"version":"0.02",
"description": "An application that displays information about altitude, lat/lon, satellites and time",
"tags": "gps",
"type": "app",
@ -753,6 +753,7 @@
{ "id": "flagrse",
"name": "Espruino Flag Raiser",
"icon": "app.png",
"version":"0.01",
"description": "App to send a command to another Espruino to cause it to raise a flag",
"tags": "",
"storage": [

View File

@ -5,3 +5,4 @@
0.06: Disable GPS time log messages, add (default=1) setting to hide log messages
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.09: Only check GPS for time after a fresh boot

View File

@ -26,11 +26,10 @@ if (!s.timeout) Bangle.setLCDPower(1);
E.setTimeZone(s.timezone);
delete s;
// check for alarms
function checkAlarm() {
var alarms = require('Storage').readJSON('alarm.json',1)||[];
var time = new Date();
var active = alarms.filter(a=>a.on&&(a.last!=time.getDate()));
if (active.length) {
var alarms = require('Storage').readJSON('alarm.json',1)||[];
var time = new Date();
var active = alarms.filter(a=>a.on&&(a.last!=time.getDate()));
if (active.length) {
active = active.sort((a,b)=>a.hr-b.hr);
var hr = time.getHours()+(time.getMinutes()/60)+(time.getSeconds()/3600);
if (!require('Storage').read("alarm.js")) {
@ -47,23 +46,4 @@ function checkAlarm() {
load("alarm.js");
},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);
delete clockApps;
}
if (clockApp) eval(clockApp);
else E.showMessage("No Clock Found");
if (!clockApp) clockApp='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 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.setLCDMode("doublebuffered");
E.showMessage("Loading..."); // avoid showing rubbish on screen
var lastFix = {
fix: 0,