mirror of https://github.com/espruino/BangleApps
boot 0.65: Only display interpreter errors if log is nonzero
parent
242eda245b
commit
f7381a7d31
|
@ -74,4 +74,5 @@
|
||||||
0.63: Only set BLE `display:1` if we have a passkey
|
0.63: Only set BLE `display:1` if we have a passkey
|
||||||
0.64: Automatically create .widcache and .clkinfocache to speed up loads
|
0.64: Automatically create .widcache and .clkinfocache to speed up loads
|
||||||
Bangle.loadWidgets overwritten with fast version on success
|
Bangle.loadWidgets overwritten with fast version on success
|
||||||
Refuse to work on firmware <2v16 and remove old polyfills
|
Refuse to work on firmware <2v16 and remove old polyfills
|
||||||
|
0.65: Only display interpreter errors if log is nonzero
|
|
@ -66,12 +66,12 @@ if (s.ble===false) boot += `if (!NRF.getSecurityStatus().connected) NRF.sleep();
|
||||||
if (s.timeout!==undefined) boot += `Bangle.setLCDTimeout(${s.timeout});\n`;
|
if (s.timeout!==undefined) boot += `Bangle.setLCDTimeout(${s.timeout});\n`;
|
||||||
if (!s.timeout) boot += `Bangle.setLCDPower(1);\n`;
|
if (!s.timeout) boot += `Bangle.setLCDPower(1);\n`;
|
||||||
boot += `E.setTimeZone(${s.timezone});`;
|
boot += `E.setTimeZone(${s.timezone});`;
|
||||||
// Draw out of memory errors onto the screen
|
// Draw out of memory errors onto the screen if logging enabled
|
||||||
boot += `E.on('errorFlag', function(errorFlags) {
|
if (s.log) boot += `E.on('errorFlag', function(errorFlags) {
|
||||||
g.reset(1).setColor("#ff0000").setFont("6x8").setFontAlign(0,1).drawString(errorFlags,g.getWidth()/2,g.getHeight()-1).flip();
|
g.reset(1).setColor("#ff0000").setFont("6x8").setFontAlign(0,1).drawString(errorFlags,g.getWidth()/2,g.getHeight()-1).flip();
|
||||||
print("Interpreter error:", errorFlags);
|
print("Interpreter error:", errorFlags);
|
||||||
E.getErrorFlags(); // clear flags so we get called next time
|
E.getErrorFlags();
|
||||||
});\n`;
|
});\n`;// E.getErrorFlags() -> clear flags so we get called next time
|
||||||
// stop users doing bad things!
|
// stop users doing bad things!
|
||||||
if (global.save) boot += `global.save = function() { throw new Error("You can't use save() on Bangle.js without overwriting the bootloader!"); }\n`;
|
if (global.save) boot += `global.save = function() { throw new Error("You can't use save() on Bangle.js without overwriting the bootloader!"); }\n`;
|
||||||
// Apply any settings-specific stuff
|
// Apply any settings-specific stuff
|
||||||
|
@ -93,7 +93,6 @@ delete Bangle.showClock;
|
||||||
if (!Bangle.showClock) boot += `Bangle.showClock = ()=>{load(".bootcde")};\n`;
|
if (!Bangle.showClock) boot += `Bangle.showClock = ()=>{load(".bootcde")};\n`;
|
||||||
delete Bangle.load;
|
delete Bangle.load;
|
||||||
if (!Bangle.load) boot += `Bangle.load = load;\n`;
|
if (!Bangle.load) boot += `Bangle.load = load;\n`;
|
||||||
let date = new Date();
|
|
||||||
|
|
||||||
// show timings
|
// show timings
|
||||||
if (DEBUG) boot += `print(".boot0",0|(Date.now()-_tm),"ms");_tm=Date.now();\n`
|
if (DEBUG) boot += `print(".boot0",0|(Date.now()-_tm),"ms");_tm=Date.now();\n`
|
||||||
|
@ -118,7 +117,7 @@ let bootFiles = require('Storage').list(/\.boot\.js$/).sort((a,b)=>{
|
||||||
bootPost += "}";
|
bootPost += "}";
|
||||||
let fileOffset,fileSize;
|
let fileOffset,fileSize;
|
||||||
/* code to output a file, plus preable and postable
|
/* code to output a file, plus preable and postable
|
||||||
when called with dst==undefined it just increments
|
when called with dst==undefined it just increments
|
||||||
fileOffset so we can see ho wbig the file has to be */
|
fileOffset so we can see ho wbig the file has to be */
|
||||||
let outputFile = (dst,src,pre,post) => {"ram";
|
let outputFile = (dst,src,pre,post) => {"ram";
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -163,14 +162,14 @@ let outputFileComplete = (dst,fn) => {
|
||||||
// we write:
|
// we write:
|
||||||
// "//"+bootFile+"\n"+require('Storage').read(bootFile)+";\n";
|
// "//"+bootFile+"\n"+require('Storage').read(bootFile)+";\n";
|
||||||
// but we need to do this without ever loading everything into RAM as some
|
// but we need to do this without ever loading everything into RAM as some
|
||||||
// boot files seem to be getting pretty big now.
|
// boot files seem to be getting pretty big now.
|
||||||
outputFile(dst,fn,"",";\n");
|
outputFile(dst,fn,"",";\n");
|
||||||
};
|
};
|
||||||
fileOffset = boot.length + bootPost.length;
|
fileOffset = boot.length + bootPost.length;
|
||||||
bootFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
|
bootFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
|
||||||
fileSize = fileOffset;
|
fileSize = fileOffset;
|
||||||
require('Storage').write('.boot0',boot,0,fileSize);
|
require('Storage').write('.boot0',boot,0,fileSize);
|
||||||
fileOffset = boot.length;
|
fileOffset = boot.length;
|
||||||
bootFiles.forEach(fn=>outputFileComplete('.boot0',fn));
|
bootFiles.forEach(fn=>outputFileComplete('.boot0',fn));
|
||||||
require('Storage').write('.boot0',bootPost,fileOffset);
|
require('Storage').write('.boot0',bootPost,fileOffset);
|
||||||
delete boot,bootPost,bootFiles;
|
delete boot,bootPost,bootFiles;
|
||||||
|
@ -186,7 +185,7 @@ fileOffset = widget.length + widgetPost.length;
|
||||||
widgetFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
|
widgetFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
|
||||||
fileSize = fileOffset;
|
fileSize = fileOffset;
|
||||||
require('Storage').write('.widcache',widget,0,fileSize);
|
require('Storage').write('.widcache',widget,0,fileSize);
|
||||||
fileOffset = widget.length;
|
fileOffset = widget.length;
|
||||||
widgetFiles.forEach(fn=>outputFileComplete('.widcache',fn));
|
widgetFiles.forEach(fn=>outputFileComplete('.widcache',fn));
|
||||||
require('Storage').write('.widcache',widgetPost,fileOffset);
|
require('Storage').write('.widcache',widgetPost,fileOffset);
|
||||||
delete widget,widgetPost,widgetFiles;
|
delete widget,widgetPost,widgetFiles;
|
||||||
|
@ -196,12 +195,12 @@ let ci = `// Made by bootupdate.js\n`;
|
||||||
if (DEBUG) ci+="var _tm=Date.now();";
|
if (DEBUG) ci+="var _tm=Date.now();";
|
||||||
outputFileComplete = (dst,fn) => {
|
outputFileComplete = (dst,fn) => {
|
||||||
outputFile(dst,fn,"try{let fn=",`;let a=fn(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${E.toJS(fn)},e,e.stack)}\n`);
|
outputFile(dst,fn,"try{let fn=",`;let a=fn(),b=menu.find(x=>x.name===a.name);if(b)b.items=b.items.concat(a.items)else menu=menu.concat(a);}catch(e){print(${E.toJS(fn)},e,e.stack)}\n`);
|
||||||
};
|
};
|
||||||
fileOffset = ci.length;
|
fileOffset = ci.length;
|
||||||
ciFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
|
ciFiles.forEach(fn=>outputFileComplete(undefined,fn)); // just get sizes
|
||||||
fileSize = fileOffset;
|
fileSize = fileOffset;
|
||||||
require('Storage').write('.clkinfocache',ci,0,fileSize);
|
require('Storage').write('.clkinfocache',ci,0,fileSize);
|
||||||
fileOffset = ci.length;
|
fileOffset = ci.length;
|
||||||
ciFiles.forEach(fn=>outputFileComplete('.clkinfocache',fn));
|
ciFiles.forEach(fn=>outputFileComplete('.clkinfocache',fn));
|
||||||
delete ci,ciFiles;
|
delete ci,ciFiles;
|
||||||
// test with require("clock_info").load()
|
// test with require("clock_info").load()
|
||||||
|
@ -211,10 +210,3 @@ E.showMessage(/*LANG*/"Reloading...");
|
||||||
// .bootcde should be run automatically after if required, since
|
// .bootcde should be run automatically after if required, since
|
||||||
// we normally get called automatically from '.boot0'
|
// we normally get called automatically from '.boot0'
|
||||||
eval(require('Storage').read('.boot0'));
|
eval(require('Storage').read('.boot0'));
|
||||||
/*
|
|
||||||
f = require("Storage").read("sched.clkinfo.js")
|
|
||||||
if (f.startsWith("Modules.addCached")) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "boot",
|
"id": "boot",
|
||||||
"name": "Bootloader",
|
"name": "Bootloader",
|
||||||
"version": "0.64",
|
"version": "0.65",
|
||||||
"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",
|
||||||
"icon": "bootloader.png",
|
"icon": "bootloader.png",
|
||||||
"type": "bootloader",
|
"type": "bootloader",
|
||||||
|
|
Loading…
Reference in New Issue