- apps/widdevst: added support for Bangle.js 2

pull/2588/head
notEvil 2023-02-20 13:05:30 +01:00
parent 6b604422cd
commit fc330c69e8
3 changed files with 11 additions and 4 deletions

View File

@ -1 +1,2 @@
0.01: First version
0.02: Support for Bangle.js 2

View File

@ -1,11 +1,11 @@
{ "id": "widdevst",
"name": "Device Status Widget",
"version": "0.01",
"version": "0.02",
"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"],
"supports": ["BANGLEJS", "BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name": "widdevst.wid.js", "url": "wid.js"}

View File

@ -24,12 +24,18 @@
}
var draw = WIDGETS.devst.draw.bind(WIDGETS.devst);
var iid = setInterval(draw, 2000);
var iid = setInterval(draw, Bangle.isLocked() ? 6e4 : 2e3);
Bangle.on('lcdPower', (on) => {
if (on) {
draw();
if (!iid) iid = setInterval(draw, 2000);
if (!iid) iid = setInterval(draw, Bangle.isLocked() ? 6e4 : 2e3);
} else if (iid) iid = clearInterval(iid);
});
Bangle.on('lock', (on) => {
if (iid) {
clearInterval(iid);
iid = setInterval(draw, on ? 6e4 : 2e3);
}
});
})();