2022-03-29 12:32:33 +00:00
|
|
|
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){
|
|
|
|
E.showMessage(/*LANG*/'Connection\nlost.', 'Bluetooth');
|
2022-03-30 05:17:52 +00:00
|
|
|
// setInterval(()=>{load();}, 3000); // clear message - this will reload the widget, resetting 'warningEnabled'.
|
2022-03-29 12:32:33 +00:00
|
|
|
|
|
|
|
WIDGETS.bluetooth_notify.warningEnabled = 0;
|
|
|
|
setTimeout('WIDGETS.bluetooth_notify.warningEnabled = 1;', 30000); // re-notify only after 30 seconds.
|
2022-03-30 08:42:00 +00:00
|
|
|
|
|
|
|
var quiet = (require('Storage').readJSON('setting.json',1)||{}).quiet;
|
|
|
|
if(!quiet){
|
|
|
|
Bangle.buzz(700, 1); // buzz on connection loss
|
|
|
|
}
|
2022-03-29 12:32:33 +00:00
|
|
|
}
|
|
|
|
WIDGETS.bluetooth_notify.draw();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
NRF.on('connect', WIDGETS.bluetooth_notify.connect);
|
|
|
|
NRF.on('disconnect', WIDGETS.bluetooth_notify.disconnect);
|