2021-06-24 13:00:40 +00:00
|
|
|
(function() {
|
|
|
|
// don't show widget if we know we have a clock app running
|
|
|
|
if (Bangle.CLOCK) return;
|
|
|
|
|
2020-05-23 21:32:33 +00:00
|
|
|
let intervalRef = null;
|
|
|
|
var width = 5 * 6*2
|
2020-03-05 13:15:27 +00:00
|
|
|
|
2020-05-23 21:32:33 +00:00
|
|
|
function draw() {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
function clearTimers(){
|
|
|
|
if(intervalRef) {
|
|
|
|
clearInterval(intervalRef);
|
|
|
|
intervalRef = null;
|
2020-01-03 07:18:44 +00:00
|
|
|
}
|
2020-05-23 21:32:33 +00:00
|
|
|
}
|
|
|
|
function startTimers(){
|
|
|
|
intervalRef = setInterval(()=>WIDGETS["wdclk"].draw(), 60*1000);
|
|
|
|
WIDGETS["wdclk"].draw();
|
|
|
|
}
|
|
|
|
Bangle.on('lcdPower', (on) => {
|
|
|
|
clearTimers();
|
|
|
|
if (on) startTimers();
|
|
|
|
});
|
2020-01-03 07:18:44 +00:00
|
|
|
|
2020-05-23 21:32:33 +00:00
|
|
|
WIDGETS["wdclk"]={area:"tr",width:width,draw:draw};
|
|
|
|
if (Bangle.isLCDOn) intervalRef = setInterval(()=>WIDGETS["wdclk"].draw(), 60*1000);
|
2020-03-05 13:15:27 +00:00
|
|
|
})()
|