diff --git a/libs/banglejs/jswrap_bangle.c b/libs/banglejs/jswrap_bangle.c index 092ca92b4a..58fbe9f35a 100644 --- a/libs/banglejs/jswrap_bangle.c +++ b/libs/banglejs/jswrap_bangle.c @@ -5621,6 +5621,12 @@ Show a 'recovery' menu that allows you to perform certain tasks on your Bangle. You can also enter this menu by restarting your Bangle while holding down the button. */ +/*JSON{ + "type" : "staticmethod", "class" : "Bangle", "name" : "showRecoveryMenu", "patch":true, + "generate_js" : "libs/js/banglejs/Bangle_showRecoveryMenu_F18.min.js", + "#if" : "defined(BANGLEJS) && defined(BANGLEJS_F18)" +} +*/ /*JSON{ "type" : "staticmethod", diff --git a/libs/js/banglejs/Bangle_showRecoveryMenu_F18.js b/libs/js/banglejs/Bangle_showRecoveryMenu_F18.js new file mode 100644 index 0000000000..c197b701c3 --- /dev/null +++ b/libs/js/banglejs/Bangle_showRecoveryMenu_F18.js @@ -0,0 +1,52 @@ +(function() { + Bangle.setUI(); + clearTimeout(); + clearInterval(); + clearWatch(); + Bangle.removeAllListeners(); + E.removeAllListeners(); + NRF.removeAllListeners(); + Bangle.setLCDBrightness(1); + E.showMenu({"":{title:"Recovery"}, + "Clean Boot": () => { + reset(); + }, + "Reboot": () => { + E.reboot(); + }, + "Turn Off": () => { + Bangle.off(); + }, + "Factory Reset": () => { + E.showPrompt("Are you sure?\nThis will remove all data.",{title:"Factory Reset"}).then(ok => { + if (!ok) return Bangle.showRecoveryMenu(); + E.showMessage("Resetting"); + Bangle.setLCDTimeout(0); + if(!NRF.getSecurityStatus().connected) + Terminal.setConsole(); + Bangle.factoryReset(); + }); + }, + "Exit": () => { + if (require("Storage").list().length>0) { + E.showMessage("Loading..."); + if(!NRF.getSecurityStatus().connected) + Terminal.setConsole(); + load(); + } else { + E.reboot(); + } + }, + "Attempt Compact": () => { + E.showMessage("Compacting...\nMay take\n5 min."); + if(!NRF.getSecurityStatus().connected) + Terminal.setConsole(); + require("Storage").compact(); + E.reboot(); + }, + "Rewrite Bootloader": () => { + setTimeout(load,1000); + eval(require("Storage").read("bootupdate.js")); + }, + }); +}) diff --git a/libs/js/banglejs/Bangle_showRecoveryMenu_F18.min.js b/libs/js/banglejs/Bangle_showRecoveryMenu_F18.min.js new file mode 100644 index 0000000000..26abcf0d3a --- /dev/null +++ b/libs/js/banglejs/Bangle_showRecoveryMenu_F18.min.js @@ -0,0 +1,2 @@ +(function(){Bangle.setUI();clearTimeout();clearInterval();clearWatch();Bangle.removeAllListeners();E.removeAllListeners();NRF.removeAllListeners();Bangle.setLCDBrightness(1);E.showMenu({"":{title:"Recovery"},"Clean Boot":()=>{reset()},Reboot:()=>{E.reboot()},"Turn Off":()=>{Bangle.off()},"Factory Reset":()=>{E.showPrompt("Are you sure?\nThis will remove all data.",{title:"Factory Reset"}).then(a=>{if(!a)return Bangle.showRecoveryMenu();E.showMessage("Resetting");Bangle.setLCDTimeout(0); +NRF.getSecurityStatus().connected||Terminal.setConsole();Bangle.factoryReset()})},Exit:()=>{0{E.showMessage("Compacting...\nMay take\n5 min.");NRF.getSecurityStatus().connected||Terminal.setConsole();require("Storage").compact();E.reboot()},"Rewrite Bootloader":()=>{setTimeout(load,1E3);eval(require("Storage").read("bootupdate.js"))}})}) \ No newline at end of file diff --git a/libs/js/update_js.sh b/libs/js/update_js.sh index eb468c361b..094602555d 100755 --- a/libs/js/update_js.sh +++ b/libs/js/update_js.sh @@ -52,6 +52,7 @@ node ../../../EspruinoDocs/bin/minify.js banglejs/Bangle_showClock.js banglejs/B node ../../../EspruinoDocs/bin/minify.js banglejs/Bangle_load.js banglejs/Bangle_load.min.js node ../../../EspruinoDocs/bin/minify.js banglejs/Bangle_setUI_F18.js banglejs/Bangle_setUI_F18.min.js node ../../../EspruinoDocs/bin/minify.js banglejs/Bangle_setUI_Q3.js banglejs/Bangle_setUI_Q3.min.js +node ../../../EspruinoDocs/bin/minify.js banglejs/Bangle_showRecoveryMenu_F18.js banglejs/Bangle_showRecoveryMenu_F18.min.js node ../../../EspruinoDocs/bin/minify.js banglejs/locale.js banglejs/locale.min.js node ../../../EspruinoDocs/bin/minify.js dickens/Bangle_setUI_DICKENS.js dickens/Bangle_setUI_DICKENS.min.js