diff --git a/apps/chargerot/ChangeLog b/apps/chargerot/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/chargerot/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/chargerot/README.md b/apps/chargerot/README.md new file mode 100644 index 000000000..764a5ffda --- /dev/null +++ b/apps/chargerot/README.md @@ -0,0 +1,10 @@ +# Charge LCD rotation + +This simple app is for handling all types of charging cradles i.e.: +- [Official Bangle.js 2 dock](https://shop.espruino.com/banglejs2-dock) +- [Many more you can 3d print](https://www.thingiverse.com/search?q=banglejs+dock&page=1&type=things&sort=relevant) + +## Setup +In app settings set desired rotation. +App will swap screen rotation when charged and return to default one (you can change this in settings app) when undocked. + diff --git a/apps/chargerot/boot.js b/apps/chargerot/boot.js new file mode 100644 index 000000000..10f7638af --- /dev/null +++ b/apps/chargerot/boot.js @@ -0,0 +1,13 @@ +(() => { + const chargingRotation = 0 | require('Storage').readJSON("chargerot.settings.json").rotate; + const defaultRotation = 0 | require('Storage').readJSON("setting.json").rotate; + Bangle.on('charging', (charging) => { + if (charging) { + g.setRotation(chargingRotation&3,chargingRotation>>2).clear(); + Bangle.showClock(); + } else { + g.setRotation(defaultRotation&3,defaultRotation>>2).clear(); + Bangle.showClock(); + } + }); +})(); diff --git a/apps/chargerot/icon.png b/apps/chargerot/icon.png new file mode 100644 index 000000000..3347098e5 Binary files /dev/null and b/apps/chargerot/icon.png differ diff --git a/apps/chargerot/metadata.json b/apps/chargerot/metadata.json new file mode 100644 index 000000000..99c97070e --- /dev/null +++ b/apps/chargerot/metadata.json @@ -0,0 +1,15 @@ +{ + "id": "chargerot", + "name": "Charge LCD rotation", + "version": "0.01", + "description": "When charging, this app can rotate your screen and revert it when unplugged. Made for all sort of cradles.", + "icon": "icon.png", + "tags": "battery", + "readme": "README.md", + "type": "bootloader", + "supports": ["BANGLEJS2"], + "storage": [ + {"name":"chargerot.boot.js","url":"boot.js"}, + {"name":"chargerot.settings.js","url":"settings.js"} + ] +} diff --git a/apps/chargerot/settings.js b/apps/chargerot/settings.js new file mode 100644 index 000000000..f7227bd72 --- /dev/null +++ b/apps/chargerot/settings.js @@ -0,0 +1,28 @@ +(function(back) { + var rotNames = [/*LANG*/"No",/*LANG*/"Rotate CW",/*LANG*/"Left Handed",/*LANG*/"Rotate CCW",/*LANG*/"Mirror"]; + var FILE = "chargerot.settings.json"; + var appSettings = Object.assign({ + rotate: 0, + }, require('Storage').readJSON(FILE, true) || {}); + + function writeSettings() { + require('Storage').writeJSON(FILE, appSettings); + } + + + E.showMenu({ + "" : { "title" : "Carging rotation" }, + "< Back" : () => back(), + 'Rotate': { + value: 0|appSettings.rotate, + min: 0, + max: rotNames.length-1, + format: v=> rotNames[v], + onchange: v => { + appSettings.rotate = 0 | v; + writeSettings(); + } + }, + }); + // If(true) big(); +}) \ No newline at end of file