From d49728fa63946544d23b4c461778adf0cc081678 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 21 Oct 2022 15:01:35 +0100 Subject: [PATCH] settings/boot update - **Rotation** allows you to rotate (or mirror) what's displayed on the screen, eg. for left-handed wearers (needs 2v16 or 2v15 cutting edge firmware to work reliably) --- apps/boot/ChangeLog | 2 ++ apps/boot/bootupdate.js | 1 + apps/boot/metadata.json | 2 +- apps/setting/ChangeLog | 1 + apps/setting/README.md | 1 + apps/setting/metadata.json | 2 +- apps/setting/settings.js | 14 ++++++++++++++ 7 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/boot/ChangeLog b/apps/boot/ChangeLog index 16252251c..7da8aef26 100644 --- a/apps/boot/ChangeLog +++ b/apps/boot/ChangeLog @@ -53,3 +53,5 @@ 0.47: Add polyfill for setUI with an object as an argument (fix regression for 2v12 devices after Layout module changed) 0.48: Workaround for BTHRM issues on Bangle.js 1 (write .boot files in chunks) 0.49: Store first found clock as a setting to speed up further boots +0.50: Allow setting of screen rotation + Remove support for 2v11 and earlier firmware diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 077b5622a..fca1c9adc 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -92,6 +92,7 @@ if (s.options) boot+=`Bangle.setOptions(${E.toJS(s.options)});\n`; if (s.brightness && s.brightness!=1) boot+=`Bangle.setLCDBrightness(${s.brightness});\n`; if (s.passkey!==undefined && s.passkey.length==6) boot+=`NRF.setSecurity({passkey:${E.toJS(s.passkey.toString())}, mitm:1, display:1});\n`; if (s.whitelist) boot+=`NRF.on('connect', function(addr) { if (!(require('Storage').readJSON('setting.json',1)||{}).whitelist.includes(addr)) NRF.disconnect(); });\n`; +if (s.rotate) boot+=`g.setRotation(${s.rotate&3},${s.rotate>>2});\n` // screen rotation // Pre-2v10 firmwares without a theme/setUI delete g.theme; // deleting stops us getting confused by our own decl. builtins can't be deleted if (!g.theme) { diff --git a/apps/boot/metadata.json b/apps/boot/metadata.json index 31e211f7c..802856245 100644 --- a/apps/boot/metadata.json +++ b/apps/boot/metadata.json @@ -1,7 +1,7 @@ { "id": "boot", "name": "Bootloader", - "version": "0.49", + "version": "0.50", "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 a11995dd4..38510ad58 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -55,3 +55,4 @@ 0.48: Allow reading custom themes from files 0.49: Now reloads settings properly after 'Calibrate Battery' 0.50: Add Bangle.js 2 touchscreen calibration - for 2v16 or 2v15 cutting edge builds +0.51: Add option for left-handed users diff --git a/apps/setting/README.md b/apps/setting/README.md index abf968f62..e5ea2b43d 100644 --- a/apps/setting/README.md +++ b/apps/setting/README.md @@ -29,6 +29,7 @@ This is Bangle.js's settings menu * **LCD Brightness** set how bright the LCD is. Due to hardware limitations in the LCD backlight, you may notice flicker if the LCD is not at 100% brightness. * **LCD Timeout** how long should the LCD stay on for if no activity is detected. 0=stay on forever +* **Rotation** allows you to rotate (or mirror) what's displayed on the screen, eg. for left-handed wearers (needs 2v16 or 2v15 cutting edge firmware to work reliably) * **Wake on X** should the given activity wake up the Bangle.js LCD? * On Bangle.js 2 when locked the touchscreen is turned off to save power. Because of this, `Wake on Touch` actually uses the accelerometer, and you need to actually tap the display to wake Bangle.js. diff --git a/apps/setting/metadata.json b/apps/setting/metadata.json index c114e9daf..210ebf0f4 100644 --- a/apps/setting/metadata.json +++ b/apps/setting/metadata.json @@ -1,7 +1,7 @@ { "id": "setting", "name": "Settings", - "version": "0.50", + "version": "0.51", "description": "A menu for setting up Bangle.js", "icon": "settings.png", "tags": "tool,system", diff --git a/apps/setting/settings.js b/apps/setting/settings.js index 36af93a8a..102708729 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -383,6 +383,8 @@ function showLCDMenu() { // converts Espruino internal unit to g function internalToG(u) { return u / 8192; } + var rotNames = [/*LANG*/"No",/*LANG*/"Rotate CW",/*LANG*/"Left Handed",/*LANG*/"Rotate CCW",/*LANG*/"Mirror"]; + const lcdMenu = { '': { 'title': 'LCD' }, '< Back': ()=>showSystemMenu(), @@ -408,6 +410,18 @@ function showLCDMenu() { Bangle.setLCDTimeout(settings.timeout); } }, + /*LANG*/'Rotate': { + value: 0|settings.rotate, + min: 0, + max: rotNames.length-1, + format: v=> rotNames[v], + onchange: v => { + settings.rotate = 0 | v; + updateSettings(); + g.setRotation(settings.rotate&3,settings.rotate>>2).clear(); + Bangle.drawWidgets(); + } + }, /*LANG*/'Wake on BTN1': { value: settings.options.wakeOnBTN1, format: boolFormat,