diff --git a/apps/widbt_notify/ChangeLog b/apps/widbt_notify/ChangeLog new file mode 100644 index 000000000..b5a50210e --- /dev/null +++ b/apps/widbt_notify/ChangeLog @@ -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. diff --git a/apps/widbt_notify/metadata.json b/apps/widbt_notify/metadata.json new file mode 100644 index 000000000..0b795c2c8 --- /dev/null +++ b/apps/widbt_notify/metadata.json @@ -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"} + ] +} diff --git a/apps/widbt_notify/widget.js b/apps/widbt_notify/widget.js new file mode 100644 index 000000000..04f91a698 --- /dev/null +++ b/apps/widbt_notify/widget.js @@ -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); diff --git a/apps/widbt_notify/widget.png b/apps/widbt_notify/widget.png new file mode 100644 index 000000000..1a884a62c Binary files /dev/null and b/apps/widbt_notify/widget.png differ