Fix GPS apps if time not set in GPS (fix #110)
parent
107d8ef7e0
commit
b93c094340
|
|
@ -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": [
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -26,44 +26,24 @@ 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) {
|
||||
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")) {
|
||||
console.log("No alarm app!");
|
||||
require('Storage').write('alarm.json',"[]")
|
||||
} else {
|
||||
var t = 3600000*(active[0].hr-hr);
|
||||
if (t<1000) t=1000;
|
||||
/* execute alarm at the correct time. We avoid execing immediately
|
||||
since this code will get called AGAIN when alarm.js is loaded. alarm.js
|
||||
will then clearInterval() to get rid of this call so it can proceed
|
||||
normally. */
|
||||
setTimeout(function() {
|
||||
load("alarm.js");
|
||||
},t);
|
||||
}
|
||||
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")) {
|
||||
console.log("No alarm app!");
|
||||
require('Storage').write('alarm.json',"[]")
|
||||
} else {
|
||||
var t = 3600000*(active[0].hr-hr);
|
||||
if (t<1000) t=1000;
|
||||
/* execute alarm at the correct time. We avoid execing immediately
|
||||
since this code will get called AGAIN when alarm.js is loaded. alarm.js
|
||||
will then clearInterval() to get rid of this call so it can proceed
|
||||
normally. */
|
||||
setTimeout(function() {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
delete clockApp;
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
0.02: Ensure screen doesn't display garbage at startup
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue