mirror of https://github.com/espruino/BangleApps
widbt_notify 0.18: Use notify lib to stop this widget clearing the screen of the running clock/app
parent
595e4a71ea
commit
a4f5978fb6
|
@ -14,3 +14,4 @@
|
||||||
0.15: Added option to hide widget when connected
|
0.15: Added option to hide widget when connected
|
||||||
0.16: Simplify code, add option to disable displaying a message
|
0.16: Simplify code, add option to disable displaying a message
|
||||||
0.17: Minor display fix
|
0.17: Minor display fix
|
||||||
|
0.18: Use notify lib to stop this widget clearing the screen of the running clock/app
|
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
"id": "widbt_notify",
|
"id": "widbt_notify",
|
||||||
"name": "Bluetooth Widget with Notification",
|
"name": "Bluetooth Widget with Notification",
|
||||||
"version": "0.17",
|
"version": "0.18",
|
||||||
"description": "Show the current Bluetooth connection status with some optional features: show message, buzz on connect/loss, hide always/if connected.",
|
"description": "Show the current Bluetooth connection status with some optional features: show message, buzz on connect/loss, hide always/if connected.",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
"tags": "widget,bluetooth",
|
"tags": "widget,bluetooth",
|
||||||
"provides_widgets" : ["bluetooth"],
|
"provides_widgets" : ["bluetooth"],
|
||||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
|
"dependencies" : { "notify":"module" },
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"widbt_notify.wid.js","url":"widget.js"},
|
{"name":"widbt_notify.wid.js","url":"widget.js"},
|
||||||
{"name":"widbt_notify.settings.js","url":"settings.js"}
|
{"name":"widbt_notify.settings.js","url":"settings.js"}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(function() {
|
{
|
||||||
// load settings
|
// load settings
|
||||||
var settings = Object.assign({
|
let settings = Object.assign({
|
||||||
showWidget: true,
|
showWidget: true,
|
||||||
buzzOnConnect: true,
|
buzzOnConnect: true,
|
||||||
buzzOnLoss: true,
|
buzzOnLoss: true,
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
}, require("Storage").readJSON("widbt_notify.json", true) || {});
|
}, require("Storage").readJSON("widbt_notify.json", true) || {});
|
||||||
|
|
||||||
// setup widget with to hide if connected and option set
|
// setup widget with to hide if connected and option set
|
||||||
var widWidth = settings.hideConnected && NRF.getSecurityStatus().connected ? 0 : 15;
|
let widWidth = settings.hideConnected && NRF.getSecurityStatus().connected ? 0 : 15;
|
||||||
|
|
||||||
// write widget with loaded settings
|
// write widget with loaded settings
|
||||||
WIDGETS.bluetooth_notify = Object.assign(settings, {
|
WIDGETS.bluetooth_notify = Object.assign(settings, {
|
||||||
|
@ -38,17 +38,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
redrawCurrentApp: function() {
|
|
||||||
if (typeof(draw) == 'function') {
|
|
||||||
g.reset().clear();
|
|
||||||
draw();
|
|
||||||
Bangle.loadWidgets();
|
|
||||||
Bangle.drawWidgets();
|
|
||||||
} else {
|
|
||||||
load(); // fallback. This might reset some variables
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onNRF: function(connect) {
|
onNRF: function(connect) {
|
||||||
// setup widget with and reload widgets to show/hide if hideConnected is enabled
|
// setup widget with and reload widgets to show/hide if hideConnected is enabled
|
||||||
if (this.hideConnected) {
|
if (this.hideConnected) {
|
||||||
|
@ -61,10 +50,10 @@
|
||||||
|
|
||||||
if (this.warningEnabled) {
|
if (this.warningEnabled) {
|
||||||
if (this.showMessage) {
|
if (this.showMessage) {
|
||||||
E.showMessage( /*LANG*/ 'Connection\n' + (connect ? /*LANG*/ 'restored.' : /*LANG*/ 'lost.'), 'Bluetooth');
|
require("notify").show({id:"widbtnotify", title:"Bluetooth", body:/*LANG*/ 'Connection\n' + (connect ? /*LANG*/ 'restored.' : /*LANG*/ 'lost.')});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
WIDGETS.bluetooth_notify.redrawCurrentApp();
|
require("notify").hide({id:"widbtnotify"});
|
||||||
}, 3000); // clear message - this will reload the widget, resetting 'warningEnabled'.
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.warningEnabled = 0;
|
this.warningEnabled = 0;
|
||||||
|
@ -87,4 +76,4 @@
|
||||||
NRF.on('connect', (addr) => WIDGETS.bluetooth_notify.onNRF(addr));
|
NRF.on('connect', (addr) => WIDGETS.bluetooth_notify.onNRF(addr));
|
||||||
NRF.on('disconnect', () => WIDGETS.bluetooth_notify.onNRF());
|
NRF.on('disconnect', () => WIDGETS.bluetooth_notify.onNRF());
|
||||||
|
|
||||||
})()
|
}
|
Loading…
Reference in New Issue