Settings.log, off,display,log, both

pull/2549/head
Hugh Barney 2023-01-31 22:18:15 +00:00
parent 418b57ed78
commit 0140cb9150
7 changed files with 17 additions and 12 deletions

View File

@ -64,3 +64,4 @@
0.55: Add toLocalISOString polyfill for pre-2v15 firmwares
Only add boot info comments if settings.bootDebug was set
If settings.bootDebug is set, output timing for each section of .boot0
0.56: Settings.log = 0,1,2,3 for off,display, log, both

View File

@ -32,14 +32,15 @@ if (s.ble!==false) {
boot += `bleServiceOptions.hid=Bangle.HID;\n`;
}
}
if (s.log==2) { // logging to file
// settings.log 0-off, 1-display, 2-log, 3-both
if (s.log>=2) { // logging to file
boot += `_DBGLOG=require("Storage").open("log.txt","a");
`;
} if (s.blerepl===false) { // If not programmable, force terminal off Bluetooth
if (s.log==2) boot += `_DBGLOG=require("Storage").open("log.txt","a");
if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a");
LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);});
LoopbackA.setConsole(true);\n`;
else if (s.log) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal
else if (s.log==1||s.log==3) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal
else boot += `E.setConsole(null,{force:true});\n`; // on new (2v05+) firmware we have E.setConsole which allows a 'null' console
/* If not programmable add our own handler for Bluetooth data
to allow Gadgetbridge commands to be received*/
@ -56,10 +57,10 @@ Bluetooth.on('line',function(l) {
try { global.GB(JSON.parse(l.slice(3,-1))); } catch(e) {}
});\n`;
} else {
if (s.log==2) boot += `_DBGLOG=require("Storage").open("log.txt","a");
if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a");
LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);});
if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`;
else if (s.log) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection)
else if (s.log==1||s.log==3) boot += `if (!NRF.getSecurityStatus().connected) Terminal.setConsole();\n`; // if showing debug, put REPL on terminal (until connection)
else boot += `Bluetooth.setConsole(true);\n`; // else if no debug, force REPL to Bluetooth
}
// we just reset, so BLE should be on.

View File

@ -1,7 +1,7 @@
{
"id": "boot",
"name": "Bootloader",
"version": "0.55",
"version": "0.56",
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
"icon": "bootloader.png",
"type": "bootloader",

View File

@ -62,3 +62,4 @@
0.55: More strings tagged for automatic translation.
0.56: make System menu items shorter and more consistant, Eg 'Clock', intead
of 'Select Clock'
0.57: Settings.log = 0,1,2,3 for off,display,log,both

View File

@ -56,9 +56,10 @@ The exact effects depend on the app. In general the watch will not wake up by i
* **Debug Info** should debug info be shown on the watch's screen or not?
* `Hide` (default) do not show debug information
* `Show` Show on the Bangle's screen (when not connected to Bluetooth or `Programmable:off`)
* `Off` (default) do not show debug information
* `Display` Show on the Bangle's screen (when not connected to Bluetooth or `Programmable:off`)
* `Log` Show on the Bangle's screen **and** write to a file called `log.txt` on Storage (when not connected to Bluetooth or `Programmable:off`). Warning - this file is appended to so may grow to be large if this is left enabled.
* `Both` Log and display on Bangle's screen
* **Compact Storage** Removes deleted/old files from Storage - this will speed up your Bangle.js
* **Rewrite Settings** Should not normally be required, but if `.boot0` has been deleted/corrupted (and so no settings are being loaded) this will fix it.
* **Flatten Battery** Turns on all devices and draws as much power as possible, attempting to flatten the Bangle.js battery. This can still take 5+ hours.

View File

@ -557,11 +557,11 @@ function showUtilMenu() {
var menu = {
'': { 'title': /*LANG*/'Utilities' },
'< Back': ()=>showMainMenu(),
/*LANG*/'Debug Info': {
value: E.clip(0|settings.log,0,2),
/*LANG*/'Debug': {
value: E.clip(0|settings.log,0,3),
min: 0,
max: 2,
format: v => [/*LANG*/"Hide",/*LANG*/"Show",/*LANG*/"Log"][E.clip(0|v,0,2)],
max: 3,
format: v => [/*LANG*/"Off",/*LANG*/"Display",/*LANG*/"Log", /*LANG*/"Both"][E.clip(0|v,0,3)],
onchange: v => {
settings.log = v;
updateSettings();

View File

@ -13,6 +13,7 @@ function draw() {
g.setFontAlign(0, 0);
g.setColor(g.theme.fg);
g.drawString(timeStr, w/2, h/2);
console.log(timeStr + ", simplest");
queueDraw();
}