widclkscrl: Draw only in draw method
parent
7d82b39a71
commit
9ea1fe4dcf
|
|
@ -16,29 +16,14 @@
|
|||
pos: 10,
|
||||
dir: -1,
|
||||
eventHandlerSet: false,
|
||||
draw: function() {
|
||||
draw: function(_w, scroll) {
|
||||
if (!this.eventHandlerSet) {
|
||||
Bangle.on('lock', (on) => {
|
||||
this.run(!on);
|
||||
});
|
||||
this.eventHandlerSet = true;
|
||||
}
|
||||
},
|
||||
run: function (on) {
|
||||
if (!Bangle.CLOCK && on && !this.interval) {
|
||||
this.text = getDateText();
|
||||
this.interval = setInterval(() => {
|
||||
this.scroll();
|
||||
}, 100);
|
||||
this.width = WIDTH+2; Bangle.drawWidgets();
|
||||
} else if (!on && this.interval) {
|
||||
clearInterval(this.interval);
|
||||
this.interval = undefined;
|
||||
this.width = 0; Bangle.drawWidgets();
|
||||
delete this.text;
|
||||
}
|
||||
},
|
||||
scroll: function() {
|
||||
if (scroll) {
|
||||
const buf = Graphics.createArrayBuffer(WIDTH,24,1,{msb:true}).setFont("Teletext5x9Ascii:1x2").setFontAlign(-1, 0);
|
||||
buf.drawString(this.text, this.pos, 12);
|
||||
|
||||
|
|
@ -59,6 +44,21 @@
|
|||
bpp:buf.getBPP(),
|
||||
buffer:buf.buffer
|
||||
}, this.x+1, this.y);
|
||||
}
|
||||
},
|
||||
run: function (on) {
|
||||
if (!Bangle.CLOCK && on && !this.interval) {
|
||||
this.text = getDateText();
|
||||
this.interval = setInterval(() => {
|
||||
this.draw(this, true);
|
||||
}, 100);
|
||||
this.width = WIDTH+2; Bangle.drawWidgets();
|
||||
} else if (!on && this.interval) {
|
||||
clearInterval(this.interval);
|
||||
delete this.interval;
|
||||
delete this.text;
|
||||
this.width = 0; Bangle.drawWidgets();
|
||||
}
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in New Issue