2021-11-25 15:50:07 +00:00
|
|
|
|
2021-10-22 10:47:23 +00:00
|
|
|
WIDGETS["messages"]={area:"tl",width:0,draw:function() {
|
|
|
|
if (!this.width) return;
|
|
|
|
var c = (Date.now()-this.t)/1000;
|
|
|
|
g.reset().setBgColor((c&1) ? "#0f0" : "#030").setColor((c&1) ? "#000" : "#fff");
|
|
|
|
g.clearRect(this.x,this.y,this.x+this.width,this.y+23);
|
|
|
|
g.setFont("6x8:1x2").setFontAlign(0,0).drawString("MESSAGES", this.x+this.width/2, this.y+12);
|
|
|
|
//if (c<60) Bangle.setLCDPower(1); // keep LCD on for 1 minute
|
2021-11-25 15:50:07 +00:00
|
|
|
let settings = require('Storage').readJSON("messages.settings.json", true) || {};
|
|
|
|
if (settings.repeat===undefined) settings.repeat = 4;
|
|
|
|
if (c<120 && (Date.now()-this.l)>settings.repeat*1000) {
|
2021-10-22 10:47:23 +00:00
|
|
|
this.l = Date.now();
|
2021-11-25 15:50:07 +00:00
|
|
|
WIDGETS["messages"].buzz(); // buzz every 4 seconds
|
2021-10-22 10:47:23 +00:00
|
|
|
}
|
|
|
|
setTimeout(()=>WIDGETS["messages"].draw(), 1000);
|
2021-11-23 16:28:34 +00:00
|
|
|
},show:function() {
|
2021-10-22 10:47:23 +00:00
|
|
|
WIDGETS["messages"].t=Date.now(); // first time
|
|
|
|
WIDGETS["messages"].l=Date.now()-10000; // last buzz
|
|
|
|
WIDGETS["messages"].width=64;
|
|
|
|
Bangle.drawWidgets();
|
|
|
|
Bangle.setLCDPower(1);// turns screen on
|
2021-11-23 16:28:34 +00:00
|
|
|
},hide:function() {
|
|
|
|
delete WIDGETS["messages"].t;
|
|
|
|
delete WIDGETS["messages"].l;
|
|
|
|
WIDGETS["messages"].width=0;
|
|
|
|
Bangle.drawWidgets();
|
2021-11-25 15:50:07 +00:00
|
|
|
},buzz:function() {
|
|
|
|
let v = (require('Storage').readJSON("messages.settings.json", true) || {}).vibrate || ".";
|
|
|
|
function b() {
|
|
|
|
var c = v[0];
|
|
|
|
v = v.substr(1);
|
|
|
|
if (c==".") Bangle.buzz().then(()=>setTimeout(b,100));
|
|
|
|
if (c=="-") Bangle.buzz(500).then(()=>setTimeout(b,100));
|
|
|
|
}
|
|
|
|
b();
|
2021-10-22 10:47:23 +00:00
|
|
|
}};
|