forked from FOSS/BangleApps
Battery widget now updates every minute with screen on, or whenever the screen first turns on
parent
6e6d078a9b
commit
0590c1eec1
|
@ -13,13 +13,27 @@ function draw() {
|
||||||
x+=16;
|
x+=16;
|
||||||
s-=16;
|
s-=16;
|
||||||
}
|
}
|
||||||
g.setColor(1,1,1);
|
g.setColor(-1);
|
||||||
g.fillRect(x,y+2,x+s-4,y+21);
|
g.fillRect(x,y+2,x+s-4,y+21);
|
||||||
g.clearRect(x+2,y+4,x+s-6,y+19);
|
g.clearRect(x+2,y+4,x+s-6,y+19);
|
||||||
g.fillRect(x+s-3,y+10,x+s,y+14);
|
g.fillRect(x+s-3,y+10,x+s,y+14);
|
||||||
g.setColor(CHARGING).fillRect(x+4,y+6,x+4+E.getBattery()*(s-12)/100,y+17);
|
g.setColor(CHARGING).fillRect(x+4,y+6,x+4+E.getBattery()*(s-12)/100,y+17);
|
||||||
g.setColor(1,1,1);
|
g.setColor(-1);
|
||||||
}
|
}
|
||||||
Bangle.on('charging',function(charging) { draw(); g.flip(); if(charging)Bangle.buzz(); });
|
Bangle.on('charging',function(charging) { draw(); g.flip(); if(charging)Bangle.buzz(); });
|
||||||
|
var batteryInterval;
|
||||||
|
Bangle.on('lcdPower', function(on) {
|
||||||
|
if (on) {
|
||||||
|
draw();
|
||||||
|
// refresh once a minute if LCD on
|
||||||
|
if (!batteryInterval)
|
||||||
|
batteryInterval = setInterval(draw, 60000);
|
||||||
|
} else {
|
||||||
|
if (batteryInterval) {
|
||||||
|
clearInterval(batteryInterval);
|
||||||
|
batteryInterval = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
WIDGETS["battery"]={draw:draw};
|
WIDGETS["battery"]={draw:draw};
|
||||||
})()
|
})()
|
||||||
|
|
Loading…
Reference in New Issue