mirror of https://github.com/espruino/BangleApps
- added app widdevst
parent
716af7c18b
commit
01eeff6fe4
|
@ -0,0 +1 @@
|
||||||
|
0.01: First version
|
|
@ -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%.
|
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -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"}
|
||||||
|
]
|
||||||
|
}
|
|
@ -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);
|
||||||
|
});
|
||||||
|
})();
|
Loading…
Reference in New Issue