From 01eeff6fe4cf5e71af16a8d7d609c7cea4eed1ad Mon Sep 17 00:00:00 2001 From: notEvil Date: Sun, 19 Feb 2023 12:53:07 +0100 Subject: [PATCH] - added app widdevst --- apps/widdevst/ChangeLog | 1 + apps/widdevst/README.md | 15 +++++++++++++++ apps/widdevst/icon.png | Bin 0 -> 4374 bytes apps/widdevst/metadata.json | 13 +++++++++++++ apps/widdevst/wid.js | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 apps/widdevst/ChangeLog create mode 100644 apps/widdevst/README.md create mode 100644 apps/widdevst/icon.png create mode 100644 apps/widdevst/metadata.json create mode 100644 apps/widdevst/wid.js diff --git a/apps/widdevst/ChangeLog b/apps/widdevst/ChangeLog new file mode 100644 index 000000000..7f837e50e --- /dev/null +++ b/apps/widdevst/ChangeLog @@ -0,0 +1 @@ +0.01: First version diff --git a/apps/widdevst/README.md b/apps/widdevst/README.md new file mode 100644 index 000000000..49affc78d --- /dev/null +++ b/apps/widdevst/README.md @@ -0,0 +1,15 @@ +# Device Status Widget + +This widget shows a rectangle containing + +- `B` if Bluetooth is on +- `C` if the compass is on +- `G` if GPS is on +- `H` if the heart rate monitor is on + +at fixed positions, and two bars + +- left to right: usage of Flash storage +- bottom to top: usage of RAM + +in green if below 50%, orange if between 50% and 80%, and red if above 80%. diff --git a/apps/widdevst/icon.png b/apps/widdevst/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..be242e1e1194ac76ea6bda5997af8c8a75d6ab79 GIT binary patch literal 4374 zcmeHKeQ*=k5kHd}8&M3k4Y=4fhiDRteY!hI*2h({BP1aSN4Bul*v8QMboXRmEa_z3 z*^&(*28Rp*=fhz_3?Y1sA;XZ+xNS&=0)rewNq}@HHBBi^a0)Y&g7DCx`5*-PPLjW- zndx{Y`Olg;-QC;W-|qf)-_E<|TxGTyvUxHDL1sAYmI`=Br7L|Z{1@8V?!epoZSHEZ zf)1m>5bx!D02Nz<00j}wiy)D|`CX>Wel-2)*PD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Zj&5B>bVUw%ri-tvYrQ>Z z+qFFY>i$=3%cuRP60sO=zR-RX$!M_+3eC}i&(yN+h%d8E;DUmVI*z< literal 0 HcmV?d00001 diff --git a/apps/widdevst/metadata.json b/apps/widdevst/metadata.json new file mode 100644 index 000000000..41cbdc028 --- /dev/null +++ b/apps/widdevst/metadata.json @@ -0,0 +1,13 @@ +{ "id": "widdevst", + "name": "Device Status Widget", + "version": "0.01", + "description": "Shows power status of Bluetooth, Compass, GPS and Heart Rate Monitor as well as storage and memory usage.", + "icon": "icon.png", + "type": "widget", + "tags": "widget,bluetooth,compass,gps,hrm", + "supports": ["BANGLEJS"], + "readme": "README.md", + "storage": [ + {"name": "widdevst.wid.js", "url": "wid.js"} + ] +} diff --git a/apps/widdevst/wid.js b/apps/widdevst/wid.js new file mode 100644 index 000000000..9920be404 --- /dev/null +++ b/apps/widdevst/wid.js @@ -0,0 +1,34 @@ +(() => { + WIDGETS.stat = {area: "tr", width: 21, draw: function() { + var x = this.x; + var y = this.y; + g.reset(); + g.clearRect(x, y, x + 20, y + 23); + g.drawRect(x + 1, y + 1, x + 19, y + 22); + g.setFont('6x8', 1); + if (NRF.getSecurityStatus().connected) g.drawString('B', x + 4, y + 3); + if (Bangle.isCompassOn()) g.drawString('C', x + 12, y + 3); + if (Bangle.isGPSOn()) g.drawString('G', x + 4, y + 13); + if (Bangle.isHRMOn()) g.drawString('H', x + 12, y + 13); + var t = require('Storage').getStats(); + var u = t.fileBytes / t.totalBytes; + g.setColor(col(u)); g.drawRect(x + 1, y + 22, x + 1 + u * 18, y + 23); + t = process.memory(false); + u = t.usage / t.total; + g.setColor(col(u)); g.drawRect(x, y + 22 - u * 21, x + 1, y + 22); + }}; + + function col(p) { + return p < 0.5 ? '#0f0' : (p < 0.8 ? '#f80' : '#f00'); + } + + var draw = WIDGETS.stat.draw.bind(WIDGETS.stat); + var iid = setInterval(draw, 2000); + + Bangle.on('lcdPower', (on) => { + if (on) { + draw(); + if (!iid) iid = setInterval(draw, 2000); + } else if (iid) iid = clearInterval(iid); + }); +})();