Move welcome loader into welcome.boot.js
parent
a96f32a015
commit
f8ef03bade
|
|
@ -2,7 +2,7 @@
|
||||||
{ "id": "boot",
|
{ "id": "boot",
|
||||||
"name": "Bootloader",
|
"name": "Bootloader",
|
||||||
"icon": "bootloader.png",
|
"icon": "bootloader.png",
|
||||||
"version":"0.13",
|
"version":"0.14",
|
||||||
"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",
|
||||||
|
|
@ -78,12 +78,12 @@
|
||||||
{ "id": "welcome",
|
{ "id": "welcome",
|
||||||
"name": "Welcome",
|
"name": "Welcome",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.05",
|
"version":"0.06",
|
||||||
"description": "Appears at first boot and explains how to use Bangle.js",
|
"description": "Appears at first boot and explains how to use Bangle.js",
|
||||||
"tags": "start,welcome",
|
"tags": "start,welcome",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"welcome.js","url":"welcome.js"},
|
{"name":"welcome.boot.js","url":"boot.js"},
|
||||||
{"name":"welcome.app.js","url":"app.js"},
|
{"name":"welcome.app.js","url":"app.js"},
|
||||||
{"name":"welcome.settings.js","url":"settings.js"},
|
{"name":"welcome.settings.js","url":"settings.js"},
|
||||||
{"name":"welcome.img","url":"app-icon.js","evaluate":true}
|
{"name":"welcome.img","url":"app-icon.js","evaluate":true}
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,4 @@
|
||||||
0.12: Add an event on BTN2 to open launcher when no clock detected (fix #147)
|
0.12: Add an event on BTN2 to open launcher when no clock detected (fix #147)
|
||||||
0.13: Now automatically load *.boot.js at startup
|
0.13: Now automatically load *.boot.js at startup
|
||||||
Move alarm code into alarm.boot.js
|
Move alarm code into alarm.boot.js
|
||||||
|
0.14: Move welcome loader into welcome.boot.js
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,6 @@ delete s;
|
||||||
// stop users doing bad things!
|
// stop users doing bad things!
|
||||||
global.save = function() { throw new Error("You can't use save() on Bangle.js without overwriting the bootloader!"); }
|
global.save = function() { throw new Error("You can't use save() on Bangle.js without overwriting the bootloader!"); }
|
||||||
// Load *.boot.js files
|
// Load *.boot.js files
|
||||||
var clockApps = require('Storage').list(/\.boot\.js/).map(bootFile=>{
|
require('Storage').list(/\.boot\.js/).map(bootFile=>{
|
||||||
eval(require('Storage').read(bootFile));
|
eval(require('Storage').read(bootFile));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,38 @@
|
||||||
// This runs after a 'fresh' boot
|
// This runs after a 'fresh' boot
|
||||||
var settings=require("Storage").readJSON('setting.json',1)||{};
|
var settings=require("Storage").readJSON('setting.json',1)||{};
|
||||||
if (!settings.welcomed && require("Storage").read("welcome.js")!==undefined) {
|
// load clock if specified
|
||||||
setTimeout(()=>load("welcome.js"));
|
var clockApp = settings.clock;
|
||||||
} else {
|
if (clockApp) clockApp = require("Storage").read(clockApp)
|
||||||
// load clock if specified
|
if (!clockApp) {
|
||||||
var clockApp = settings.clock;
|
var clockApps = require("Storage").list(/\.info$/).map(app=>require("Storage").readJSON(app,1)||{}).filter(app=>app.type=="clock").sort((a, b) => a.sortorder - b.sortorder);
|
||||||
if (clockApp) clockApp = require("Storage").read(clockApp)
|
if (clockApps && clockApps.length > 0)
|
||||||
if (!clockApp) {
|
clockApp = require("Storage").read(clockApps[0].src);
|
||||||
var clockApps = require("Storage").list(/\.info$/).map(app=>require("Storage").readJSON(app,1)||{}).filter(app=>app.type=="clock").sort((a, b) => a.sortorder - b.sortorder);
|
delete clockApps;
|
||||||
if (clockApps && clockApps.length > 0)
|
}
|
||||||
clockApp = require("Storage").read(clockApps[0].src);
|
if (!clockApp) clockApp=`E.showMessage("No Clock Found");
|
||||||
delete clockApps;
|
setWatch(() => {
|
||||||
}
|
Bangle.showLauncher();
|
||||||
if (!clockApp) clockApp=`E.showMessage("No Clock Found");
|
}, BTN2, {repeat:false,edge:"falling"});)
|
||||||
setWatch(() => {
|
`;
|
||||||
Bangle.showLauncher();
|
delete settings;
|
||||||
}, BTN2, {repeat:false,edge:"falling"});)
|
// check to see if our clock is wrong - if it is use GPS time
|
||||||
`;
|
if ((new Date()).getFullYear()==1970) {
|
||||||
delete settings;
|
E.showMessage("Searching for\nGPS time");
|
||||||
// check to see if our clock is wrong - if it is use GPS time
|
Bangle.on('GPS',function cb(g) {
|
||||||
if ((new Date()).getFullYear()==1970) {
|
Bangle.setGPSPower(0);
|
||||||
E.showMessage("Searching for\nGPS time");
|
Bangle.removeListener("GPS",cb);
|
||||||
Bangle.on('GPS',function cb(g) {
|
if (!g.time || (g.time.getFullYear()<2000) ||
|
||||||
Bangle.setGPSPower(0);
|
(g.time.getFullYear()==2250)) {
|
||||||
Bangle.removeListener("GPS",cb);
|
// GPS receiver's time not set - just boot clock anyway
|
||||||
if (!g.time || (g.time.getFullYear()<2000) ||
|
eval(clockApp);delete clockApp;
|
||||||
(g.time.getFullYear()==2250)) {
|
return;
|
||||||
// GPS receiver's time not set - just boot clock anyway
|
}
|
||||||
eval(clockApp);delete clockApp;
|
// We have a GPS time. Set time and reboot (to load alarms properly)
|
||||||
return;
|
setTime(g.time.getTime()/1000);
|
||||||
}
|
load();
|
||||||
// We have a GPS time. Set time and reboot (to load alarms properly)
|
});
|
||||||
setTime(g.time.getTime()/1000);
|
Bangle.setGPSPower(1);
|
||||||
load();
|
} else {
|
||||||
});
|
eval(clockApp);
|
||||||
Bangle.setGPSPower(1);
|
delete clockApp;
|
||||||
} else {
|
|
||||||
eval(clockApp);
|
|
||||||
delete clockApp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@
|
||||||
0.03: BTN3 now won't restart when at the end
|
0.03: BTN3 now won't restart when at the end
|
||||||
0.04: Fix regression after tweaks to Storage.readJSON
|
0.04: Fix regression after tweaks to Storage.readJSON
|
||||||
0.05: Move configuration into App/widget settings
|
0.05: Move configuration into App/widget settings
|
||||||
|
0.06: Move loader into welcome.boot.js
|
||||||
|
|
|
||||||
|
|
@ -283,16 +283,12 @@ setWatch(()=>move(1), BTN3, {repeat:true});
|
||||||
setWatch(()=>{
|
setWatch(()=>{
|
||||||
// If we're on the last page
|
// If we're on the last page
|
||||||
if (sceneNumber == scenes.length-1) {
|
if (sceneNumber == scenes.length-1) {
|
||||||
var settings = require("Storage").readJSON('setting.json',1)||{};
|
|
||||||
settings.welcomed = true;
|
|
||||||
require("Storage").write('setting.json',settings);
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
}, BTN2, {repeat:true,edge:"rising"});
|
}, BTN2, {repeat:true,edge:"rising"});
|
||||||
setWatch(()=>move(-1), BTN1, {repeat:true});
|
setWatch(()=>move(-1), BTN1, {repeat:true});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Bangle.setLCDTimeout(0);
|
Bangle.setLCDTimeout(0);
|
||||||
Bangle.setLCDPower(1);
|
Bangle.setLCDPower(1);
|
||||||
move(0);
|
move(0);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
(function() {
|
||||||
|
let s = require('Storage').readJSON('setting.json', 1) || {}
|
||||||
|
if (!s.welcomed && require('Storage').read('welcome.app.js')) {
|
||||||
|
setTimeout(() => {
|
||||||
|
s.welcomed = true
|
||||||
|
require('Storage').write('setting.json', s)
|
||||||
|
load('welcome.app.js')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
eval(require("Storage").read("welcome.app.js"))
|
|
||||||
Loading…
Reference in New Issue