boot 0.35: Add Bangle.appRect polyfill

Don't set beep vibration up on Bangle.js 2 (built in)
settings 0.31: Remove Bangle 1 settings when running on Bangle 2
pull/865/head
Gordon Williams 2021-10-27 16:49:53 +01:00
parent 641cd01230
commit d771a6a732
5 changed files with 24 additions and 10 deletions

View File

@ -16,7 +16,7 @@
{
"id": "boot",
"name": "Bootloader",
"version": "0.34",
"version": "0.35",
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
"icon": "bootloader.png",
"type": "bootloader",
@ -272,7 +272,7 @@
{
"id": "setting",
"name": "Settings",
"version": "0.30",
"version": "0.31",
"description": "A menu for setting up Bangle.js",
"icon": "settings.png",
"tags": "tool,system",

View File

@ -37,3 +37,5 @@
0.33: Add E.showScroller polyfill
0.34: Use Storage.hash if available
Rearrange NRF.setServices to allow .boot.js files to add services (eg ANCS)
0.35: Add Bangle.appRect polyfill
Don't set beep vibration up on Bangle.js 2 (built in)

View File

@ -3,7 +3,7 @@ recalculates, but this avoids us doing a whole bunch of reconfiguration most
of the time. */
E.showMessage("Updating boot0...");
var s = require('Storage').readJSON('setting.json',1)||{};
var isB2 = process.env.HWVERSION; // Is Bangle.js 2
var BANGLEJS2 = process.env.HWVERSION==2; // Is Bangle.js 2
var boot = "";
if (require('Storage').hash) { // new in 2v11 - helps ensure files haven't changed
var CRC = E.CRC32(require('Storage').read('setting.json'))+require('Storage').hash(/\.boot\.js/);
@ -55,7 +55,7 @@ boot += `E.setTimeZone(${s.timezone});`;
if (!Bangle.F_BEEPSET) {
if (!s.vibrate) boot += `Bangle.buzz=Promise.resolve;\n`
if (s.beep===false) boot += `Bangle.beep=Promise.resolve;\n`
else if (s.beep=="vib") boot += `Bangle.beep = function (time, freq) {
else if (s.beep=="vib" && !BANGLEJS2) boot += `Bangle.beep = function (time, freq) {
return new Promise(function(resolve) {
if ((0|freq)<=0) freq=4000;
if ((0|time)<=0) time=200;
@ -182,6 +182,11 @@ if (!g.wrapString) { // added in 2v11 - this is a limited functionality polyfill
}
return lines;
};\n`;
};
delete Bangle.appRect; // deleting stops us getting confused by our own decl. builtins can't be deleted
if (!Bangle.appRect) { // added in 2v11 - polyfill for older firmwares
boot += `Bangle.appRect = ((y,w,h)=>({x:0,y:0,w:w,h:h,x2:w-1,y2:h-1}))(g.getWidth(),g.getHeight());
(lw=>{ Bangle.loadWidgets = () => { lw(); Bangle.appRect = ((y,w,h)=>({x:0,y:y,w:w,h:h-y,x2:w-1,y2:h-(1+h)}))(global.WIDGETS?24:0,g.getWidth(),g.getHeight()); }; })(Bangle.loadWidgets);\n`;
}
// Append *.boot.js files

View File

@ -32,4 +32,5 @@
0.27: Add Theme menu
0.28: Update Quiet Mode widget (if present)
0.29: Add Customize to Theme menu
0.30: Move '< Back' to the top of menus
0.30: Move '< Back' to the top of menus
0.31: Remove Bangle 1 settings when running on Bangle 2

View File

@ -1,6 +1,7 @@
Bangle.loadWidgets();
Bangle.drawWidgets();
const BANGLEJS2 = process.env.HWVERSION==2;
const storage = require('Storage');
let settings;
@ -71,8 +72,8 @@ if (!('qmOptions' in settings)) settings.qmOptions = {}; // easier if this alway
const boolFormat = v => v ? "On" : "Off";
function showMainMenu() {
var beepV = [false, true, "vib"];
var beepN = ["Off", "Piezo", "Vibrate"];
var beepV = BANGLEJS2 ? [false,true] : [false, true, "vib"];
var beepN = BANGLEJS2 ? ["Off","On"] : ["Off", "Piezo", "Vibrate"];
const mainmenu = {
'': { 'title': 'Settings' },
'< Back': ()=>load(),
@ -119,6 +120,7 @@ function showMainMenu() {
'Reset Settings': ()=>showResetMenu(),
'Turn Off': ()=>{ if (Bangle.softOff) Bangle.softOff(); else Bangle.off() },
};
return E.showMenu(mainmenu);
}
@ -356,7 +358,10 @@ function showLCDMenu() {
settings.options.wakeOnBTN1 = !settings.options.wakeOnBTN1;
updateOptions();
}
},
}
};
if (!BANGLEJS2)
Object.assign(lcdMenu, {
'Wake on BTN2': {
value: settings.options.wakeOnBTN2,
format: boolFormat,
@ -372,7 +377,8 @@ function showLCDMenu() {
settings.options.wakeOnBTN3 = !settings.options.wakeOnBTN3;
updateOptions();
}
},
}});
Object.assign(lcdMenu, {
'Wake on FaceUp': {
value: settings.options.wakeOnFaceUp,
format: boolFormat,
@ -427,7 +433,7 @@ function showLCDMenu() {
updateOptions();
}
}
}
});
return E.showMenu(lcdMenu)
}
function showQuietModeMenu() {