BangleApps/apps/widclkbttm/widclkbttm.wid.js

21 lines
805 B
JavaScript
Raw Normal View History

2023-01-09 14:29:44 +00:00
WIDGETS["wdclkbttm"]={area:"br",width:60,draw:function() {
2023-01-05 21:44:31 +00:00
console.log("clock? "+Bangle.CLOCK);
if (Bangle.CLOCK){
2023-01-09 14:29:44 +00:00
return; //avoid 2 clocks
2023-01-05 22:04:15 +00:00
}
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
2023-01-05 21:44:31 +00:00
this.width = Bangle.CLOCK?0:60;
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
2021-09-14 11:06:18 +00:00
}
if (!this.width) return; // if size not right, return
2022-12-15 22:59:52 +00:00
g.reset().setFont("6x8", 2).setFontAlign(-1, 0);
var time = require("locale").time(new Date(),1);
g.drawString(time, this.x, this.y+11, true); // 5 * 6*2 = 60
// queue draw in one minute
if (this.drawTimeout) clearTimeout(this.drawTimeout);
this.drawTimeout = setTimeout(()=>{
this.drawTimeout = undefined;
this.draw();
}, 60000 - (Date.now() % 60000));
}};