From 0140cb91509aab8a08b10435f924bdf123d15ff4 Mon Sep 17 00:00:00 2001 From: Hugh Barney Date: Tue, 31 Jan 2023 22:18:15 +0000 Subject: [PATCH 1/5] Settings.log, off,display,log, both --- apps/boot/ChangeLog | 1 + apps/boot/bootupdate.js | 11 ++++++----- apps/boot/metadata.json | 2 +- apps/setting/ChangeLog | 1 + apps/setting/README.md | 5 +++-- apps/setting/settings.js | 8 ++++---- apps/simplest/simplest.app.js | 1 + 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/apps/boot/ChangeLog b/apps/boot/ChangeLog index 780d9cc7d..a63a54eaf 100644 --- a/apps/boot/ChangeLog +++ b/apps/boot/ChangeLog @@ -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 diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 112dfeba8..72eb4afab 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -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. diff --git a/apps/boot/metadata.json b/apps/boot/metadata.json index 455563a16..9f64b672b 100644 --- a/apps/boot/metadata.json +++ b/apps/boot/metadata.json @@ -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", diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog index 85ccfa1a7..9a5579f07 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -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 diff --git a/apps/setting/README.md b/apps/setting/README.md index e5ea2b43d..2a7f7ee9c 100644 --- a/apps/setting/README.md +++ b/apps/setting/README.md @@ -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. diff --git a/apps/setting/settings.js b/apps/setting/settings.js index a877ec79c..bc5f2a74a 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -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(); diff --git a/apps/simplest/simplest.app.js b/apps/simplest/simplest.app.js index 4038212d0..b1e22743d 100644 --- a/apps/simplest/simplest.app.js +++ b/apps/simplest/simplest.app.js @@ -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(); } From 8aabecd53c232fccab57670456b8fd4d7a02b703 Mon Sep 17 00:00:00 2001 From: Hugh Barney Date: Tue, 31 Jan 2023 23:46:58 +0000 Subject: [PATCH 2/5] fixed setting version --- apps/setting/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/setting/metadata.json b/apps/setting/metadata.json index 92fc75915..6d5739d03 100644 --- a/apps/setting/metadata.json +++ b/apps/setting/metadata.json @@ -1,7 +1,7 @@ { "id": "setting", "name": "Settings", - "version": "0.56", + "version": "0.57", "description": "A menu for setting up Bangle.js", "icon": "settings.png", "tags": "tool,system", From e0929fb90e2d2b27d98aceea5e1b86b038359159 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 1 Feb 2023 08:47:48 +0000 Subject: [PATCH 3/5] Tweaks to maybe make this work --- apps/boot/bootupdate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 72eb4afab..f8fab16a1 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -37,10 +37,10 @@ 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"); -LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);}); + if (s.log>=2) { boot += `_DBGLOG=require("Storage").open("log.txt","a");`; +LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); LoopbackA.setConsole(true);\n`; - else if (s.log==1||s.log==3) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal + } else if (s.log==1) 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*/ From 07f83d50df9d24d1d1da07693d7853e20987ea33 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 1 Feb 2023 08:48:56 +0000 Subject: [PATCH 4/5] one more tweak --- apps/boot/bootupdate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index f8fab16a1..4e4af928d 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -58,7 +58,7 @@ Bluetooth.on('line',function(l) { });\n`; } else { if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); -LoopbackB.on('data',function(d) {_DBGLOG.write(d);Terminal.write(d);}); +LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`; 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 From 6befce43e50ec5853b7759985496072862827a4c Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 1 Feb 2023 08:56:42 +0000 Subject: [PATCH 5/5] oops --- apps/boot/bootupdate.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 4e4af928d..d929b26a0 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -33,11 +33,8 @@ if (s.ble!==false) { } } // 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.blerepl===false) { // If not programmable, force terminal off Bluetooth + if (s.log>=2) { boot += `_DBGLOG=require("Storage").open("log.txt","a"); LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); LoopbackA.setConsole(true);\n`; } else if (s.log==1) boot += `Terminal.setConsole(true);\n`; // if showing debug, force REPL onto terminal @@ -60,7 +57,7 @@ Bluetooth.on('line',function(l) { if (s.log>=2) boot += `_DBGLOG=require("Storage").open("log.txt","a"); LoopbackB.on('data',function(d) {_DBGLOG.write(d);${(s.log==3)?"Terminal.write(d);":""}}); if (!NRF.getSecurityStatus().connected) LoopbackA.setConsole();\n`; - 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 if (s.log==1) 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.