mirror of https://github.com/espruino/BangleApps
More fixes
parent
d2a1c7658f
commit
237cc63239
|
@ -1,10 +1,10 @@
|
|||
(function(){
|
||||
const intervalLow = 60000; // update time when not charging
|
||||
const intervalLow = 60000; // update time when not charging
|
||||
const intervalHigh = 2000; // update time when charging
|
||||
var old_l;
|
||||
|
||||
old_x = this.x;
|
||||
old_y = this.y;
|
||||
var old_x = this.x;
|
||||
var old_y = this.y;
|
||||
|
||||
|
||||
let COLORS = {
|
||||
|
@ -22,6 +22,8 @@
|
|||
};
|
||||
|
||||
function draw() {
|
||||
if (typeof old_x === 'undefined') old_x = this.x;
|
||||
if (typeof old_y === 'undefined') old_y = this.y;
|
||||
var s = 29;
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
|
@ -29,16 +31,21 @@
|
|||
const l = E.getBattery();
|
||||
let xl = x+4+l*(s-12)/100;
|
||||
if (l != old_l){ // Delete the old value from screen
|
||||
old_l = l;
|
||||
let xl_old = x+4+old_l*(s-12)/100;
|
||||
g.setColor(COLORS.white);
|
||||
// g.fillRect(x+2,y+5,x+s-6,y+18);
|
||||
g.fillRect(x,y,xl+4,y+16+3); //Clear
|
||||
g.setFontAlign(0,0);
|
||||
g.setFont('Vector',16);
|
||||
//g.fillRect(old_x,old_y,old_x+4+l*(s-12)/100,old_y+16+3); // clear (lazy)
|
||||
g.drawString(old_l, old_x + 14, old_y + 10);
|
||||
g.fillRect(x+4,y+14+3,xl_old,y+16+3); // charging bar
|
||||
old_l = l;
|
||||
}
|
||||
|
||||
//console.log(old_x);
|
||||
old_x = this.x;
|
||||
old_y = this.y;
|
||||
|
||||
g.setColor(levelColor(l));
|
||||
g.fillRect(x+4,y+14+3,xl,y+16+3); // charging bar
|
||||
|
@ -48,14 +55,15 @@
|
|||
g.setFontAlign(0,0);
|
||||
g.setFont('Vector',16);
|
||||
g.drawString(l, x + 14, y + 10);
|
||||
//g.drawString(x, 110, 5); //debug
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (Bangle.isCharging()) changeInterval(id, intervalHigh);
|
||||
else changeInterval(id, intervalLow);
|
||||
}
|
||||
|
||||
old_x = this.x;
|
||||
old_y = this.y;
|
||||
|
||||
|
||||
Bangle.on('charging',function(charging) { draw(); });
|
||||
var id = setInterval(()=>WIDGETS["wid_a_battery_widget"].draw(), intervalLow);
|
||||
|
|
Loading…
Reference in New Issue