widget 'widbt_notify'

New Widget 'widbt_notify' is a bluetooth widget, that vibrates, when the connection gets lost.
master
KungPhoo 2022-03-29 14:32:33 +02:00
parent 30c946ceaa
commit 8df137b21d
4 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,10 @@
0.02: Tweaks for variable size widget system
0.03: Ensure redrawing works with variable size widget system
0.04: Fix automatic update of Bluetooth connection status
0.05: Make Bluetooth widget thinner, and when on a bright theme use light grey for disabled color
0.06: Tweaking colors for dark/light themes and low bpp screens
0.07: Memory usage improvements
0.08: Disable LCD on, on bluetooth status change
0.09: Vibrate on connection loss
0.10: Bug fix
0.11: Avoid too many notifications. Change disconnected colour to red.

View File

@ -0,0 +1,13 @@
{
"id": "widbt_notify",
"name": "Bluetooth Widget with Notification",
"version": "0.11",
"description": "Show the current Bluetooth connection status in the top right of the clock and vibrate when disconnected.",
"icon": "widget.png",
"type": "widget",
"tags": "widget,bluetooth",
"supports": ["BANGLEJS","BANGLEJS2"],
"storage": [
{"name":"widbt_notify.wid.js","url":"widget.js"}
]
}

View File

@ -0,0 +1,33 @@
WIDGETS.bluetooth_notify = {
area: "tr",
width: 15,
warningEnabled: 1,
draw: function() {
g.reset();
if (NRF.getSecurityStatus().connected) {
g.setColor((g.getBPP() > 8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f"));
} else {
// g.setColor(g.theme.dark ? "#666" : "#999");
g.setColor("#f00"); // red is easier to distinguish from blue
}
g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="), 2 + this.x, 2 + this.y);
},
connect: function() {
WIDGETS.bluetooth_notify.draw();
},
disconnect: function() {
if(WIDGETS.bluetooth_notify.warningEnabled == 1){
Bangle.buzz(700, 1); // buzz on connection loss
E.showMessage(/*LANG*/'Connection\nlost.', 'Bluetooth');
setInterval(()=>{load();}, 3000); // clear message
WIDGETS.bluetooth_notify.warningEnabled = 0;
setTimeout('WIDGETS.bluetooth_notify.warningEnabled = 1;', 30000); // re-notify only after 30 seconds.
}
WIDGETS.bluetooth_notify.draw();
}
};
NRF.on('connect', WIDGETS.bluetooth_notify.connect);
NRF.on('disconnect', WIDGETS.bluetooth_notify.disconnect);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB