mirror of https://github.com/espruino/BangleApps
Fixing refresh issues
parent
d2597b3201
commit
e6515080e8
|
@ -3,3 +3,4 @@
|
||||||
0.03: Support dark themes
|
0.03: Support dark themes
|
||||||
0.04: Increase screen update rate when charging
|
0.04: Increase screen update rate when charging
|
||||||
0.05: Deleting Background - making Font larger
|
0.05: Deleting Background - making Font larger
|
||||||
|
0.06: Fixing refresh issues
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "A Battery Widget (with percentage) - Hanks Mod",
|
"name": "A Battery Widget (with percentage) - Hanks Mod",
|
||||||
"shortName":"H Battery Widget",
|
"shortName":"H Battery Widget",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"version":"0.04",
|
"version":"0.06",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(function(){
|
(function(){
|
||||||
const intervalLow = 60000; // update time when not charging
|
const intervalLow = 60000; // update time when not charging
|
||||||
const intervalHigh = 2000; // update time when charging
|
const intervalHigh = 2000; // update time when charging
|
||||||
|
var old_l;
|
||||||
|
|
||||||
let COLORS = {
|
let COLORS = {
|
||||||
'white': g.theme.dark ? "#000" : "#fff",
|
'white': g.theme.dark ? "#000" : "#fff",
|
||||||
|
@ -19,26 +20,24 @@
|
||||||
function draw() {
|
function draw() {
|
||||||
var s = 29;
|
var s = 29;
|
||||||
var x = this.x, y = this.y;
|
var x = this.x, y = this.y;
|
||||||
|
|
||||||
const l = E.getBattery();
|
const l = E.getBattery();
|
||||||
|
|
||||||
let xl = x+4+l*(s-12)/100;
|
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.setColor(COLORS.white);
|
||||||
// g.fillRect(x+2,y+5,x+s-6,y+18);
|
// g.fillRect(x+2,y+5,x+s-6,y+18);
|
||||||
|
|
||||||
g.fillRect(x,y,xl+4,y+16+3); //Clear
|
g.fillRect(x,y,xl+4,y+16+3); //Clear
|
||||||
|
g.setFontAlign(0,0);
|
||||||
|
g.setFont('Vector',16);
|
||||||
|
g.drawString(old_l, x + 14, y + 10);
|
||||||
|
g.fillRect(x+4,y+14+3,xl_old,y+16+3); // charging bar
|
||||||
|
}
|
||||||
|
|
||||||
g.setColor(levelColor(l));
|
g.setColor(levelColor(l));
|
||||||
// g.fillRect(x+1,y+3,x+s-5,y+4);
|
|
||||||
// g.fillRect(x+1,y+19,x+s-5,y+20);
|
|
||||||
// g.fillRect(x,y+4,x+1,y+19);
|
|
||||||
// g.fillRect(x+s-5,y+4,x+s-4,y+19);
|
|
||||||
//g.fillRect(x+s-3,y+8,x+s-2,y+16); // tip of the battery
|
|
||||||
g.fillRect(x+4,y+14+3,xl,y+16+3); // charging bar
|
g.fillRect(x+4,y+14+3,xl,y+16+3); // charging bar
|
||||||
|
g.fillRect((x+4+100*(s-12)/100)-1,y+14+3,x+4+100*(s-12)/100,y+16+3); // charging bar "full mark"
|
||||||
g.fillRect((x+4+100*(s-12)/100)-1,y+14+3,x+4+100*(s-12)/100,y+16+3); // charging bar full
|
// Show percentage
|
||||||
|
|
||||||
g.setColor(COLORS.black);
|
g.setColor(COLORS.black);
|
||||||
g.setFontAlign(0,0);
|
g.setFontAlign(0,0);
|
||||||
g.setFont('Vector',16);
|
g.setFont('Vector',16);
|
||||||
|
@ -48,7 +47,6 @@
|
||||||
else changeInterval(id, intervalLow);
|
else changeInterval(id, intervalLow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bangle.on('charging',function(charging) { draw(); });
|
Bangle.on('charging',function(charging) { draw(); });
|
||||||
var id = setInterval(()=>WIDGETS["wid_a_battery_widget"].draw(), intervalLow);
|
var id = setInterval(()=>WIDGETS["wid_a_battery_widget"].draw(), intervalLow);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue