From 8df137b21ddfa41cebd26f628b4b6413c34c593b Mon Sep 17 00:00:00 2001 From: KungPhoo Date: Tue, 29 Mar 2022 14:32:33 +0200 Subject: [PATCH] widget 'widbt_notify' New Widget 'widbt_notify' is a bluetooth widget, that vibrates, when the connection gets lost. --- apps/widbt_notify/ChangeLog | 10 ++++++++++ apps/widbt_notify/metadata.json | 13 +++++++++++++ apps/widbt_notify/widget.js | 33 ++++++++++++++++++++++++++++++++ apps/widbt_notify/widget.png | Bin 0 -> 1119 bytes 4 files changed, 56 insertions(+) create mode 100644 apps/widbt_notify/ChangeLog create mode 100644 apps/widbt_notify/metadata.json create mode 100644 apps/widbt_notify/widget.js create mode 100644 apps/widbt_notify/widget.png 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 0000000000000000000000000000000000000000..1a884a62c1029ae43243f8f58ef9dc3a3327e437 GIT binary patch literal 1119 zcmV-l1fctgP)cE5(396`@Dz$wLqIPzYppJ*B(brZX|I zHChYW;Hm1lL~9feUi^283bm!!Ka0DG`v(zZvk8h?W%2@c?XT zES*ZPJU3a{7h{cB0RRrPTh=dGr*a^!0&xQX?DMczGEQwQ4)Y`c0EQJR_Oa?r)W%5x z0HhI_x1HK2pc0j7k^sKW*iQXQ=2YX6D9n-q_%qO+(!1;R%(3!ggBm9SkZ!j|fYm^E zR%O?(qZ5_=gLo$b@WZ#`wXJ`4=)@t~Y>Yv)Y!7y;OB zeO8rs?l*_RK!7NCKLhRU0}||esEhzCyx)O;I=Y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