2021-10-06 09:13:26 +00:00
|
|
|
/* Simple clock that appears in the widget bar if no other clock
|
|
|
|
is running. We update once per minute, but don't bother stopping
|
|
|
|
if the */
|
2022-10-28 11:21:27 +00:00
|
|
|
WIDGETS["wdclk"]={area:"tl",width:Bangle.CLOCK?0:52/* g.stringWidth("00:00") */,draw:function() {
|
|
|
|
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
|
|
|
|
this.width = Bangle.CLOCK?0:52;
|
|
|
|
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
|
|
|
|
}
|
|
|
|
if (!this.width) return; // if size not right, return
|
|
|
|
g.reset().setFontCustom(atob("AAAAAAAAAAIAAAQCAQAAAd0BgMBdwAAAAAAAdwAB0RiMRcAAAERiMRdwAcAQCAQdwAcERiMRBwAd0RiMRBwAAEAgEAdwAd0RiMRdwAcERiMRdwAFAAd0QiEQdwAdwRCIRBwAd0BgMBAAABwRCIRdwAd0RiMRAAAd0QiEQAAAAAAAAAA="), 32, atob("BgAAAAAAAAAAAAAAAAYCAAYGBgYGBgYGBgYCAAAAAAAABgYGBgYG"), 512+9);
|
2021-10-06 09:13:26 +00:00
|
|
|
var time = require("locale").time(new Date(),1);
|
|
|
|
g.drawString(time, this.x, this.y+3, true); // 5 * 6*2 = 60
|
|
|
|
// queue draw in one minute
|
2021-10-06 19:14:33 +00:00
|
|
|
if (this.drawTimeout) clearTimeout(this.drawTimeout);
|
2021-10-06 09:13:26 +00:00
|
|
|
this.drawTimeout = setTimeout(()=>{
|
|
|
|
this.drawTimeout = undefined;
|
|
|
|
this.draw();
|
|
|
|
}, 60000 - (Date.now() % 60000));
|
|
|
|
}};
|