Handling exceptions

pull/2085/head
Hank 2022-08-11 14:56:37 +02:00
parent 2e8ded053b
commit 61b28cb47c
3 changed files with 9 additions and 8 deletions

View File

@ -4,4 +4,5 @@
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 0.06: Fixing refresh issues
0.07: Fixed position after unlocking 0.07: Fixed position after unlocking
0.08: Handling exceptions

View File

@ -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.07", "version":"0.08",
"type": "widget", "type": "widget",
"supports": ["BANGLEJS", "BANGLEJS2"], "supports": ["BANGLEJS", "BANGLEJS2"],
"readme": "README.md", "readme": "README.md",

View File

@ -29,9 +29,9 @@
var y = this.y; var y = this.y;
if ((typeof x === 'undefined') || (typeof y === 'undefined')) { if ((typeof x === 'undefined') || (typeof y === 'undefined')) {
} else { } else {
const l = E.getBattery(); const l = E.getBattery(); // debug: Math.floor(Math.random() * 101);
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 if ((l != old_l) && (typeof old_l != 'undefined') ){ // Delete the old value from screen
let xl_old = x+4+old_l*(s-12)/100; 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);
@ -41,9 +41,9 @@
//g.fillRect(old_x,old_y,old_x+4+l*(s-12)/100,old_y+16+3); // clear (lazy) //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.drawString(old_l, old_x + 14, old_y + 10);
g.fillRect(x+4,y+14+3,xl_old,y+16+3); // charging bar g.fillRect(x+4,y+14+3,xl_old,y+16+3); // charging bar
old_l = l;
} }
old_l = l;
//console.log(old_x); //console.log(old_x);
g.setColor(levelColor(l)); g.setColor(levelColor(l));
@ -64,7 +64,7 @@
} }
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["hwid_a_battery_widget"].draw(), intervalLow);
WIDGETS["wid_a_battery_widget"]={area:"tr",width:30,draw:draw}; WIDGETS["hwid_a_battery_widget"]={area:"tr",width:30,draw:draw};
})(); })();