diff --git a/apps/hwid_a_battery_widget/ChangeLog b/apps/hwid_a_battery_widget/ChangeLog index da289abff..cbdccfecf 100644 --- a/apps/hwid_a_battery_widget/ChangeLog +++ b/apps/hwid_a_battery_widget/ChangeLog @@ -4,4 +4,5 @@ 0.04: Increase screen update rate when charging 0.05: Deleting Background - making Font larger 0.06: Fixing refresh issues -0.07: Fixed position after unlocking \ No newline at end of file +0.07: Fixed position after unlocking +0.08: Handling exceptions \ No newline at end of file diff --git a/apps/hwid_a_battery_widget/metadata.json b/apps/hwid_a_battery_widget/metadata.json index 38fd503a2..29b0540c2 100644 --- a/apps/hwid_a_battery_widget/metadata.json +++ b/apps/hwid_a_battery_widget/metadata.json @@ -3,7 +3,7 @@ "name": "A Battery Widget (with percentage) - Hanks Mod", "shortName":"H Battery Widget", "icon": "widget.png", - "version":"0.07", + "version":"0.08", "type": "widget", "supports": ["BANGLEJS", "BANGLEJS2"], "readme": "README.md", diff --git a/apps/hwid_a_battery_widget/widget.js b/apps/hwid_a_battery_widget/widget.js index bd1c4e0c5..e42c15355 100644 --- a/apps/hwid_a_battery_widget/widget.js +++ b/apps/hwid_a_battery_widget/widget.js @@ -29,9 +29,9 @@ var y = this.y; if ((typeof x === 'undefined') || (typeof y === 'undefined')) { } else { - const l = E.getBattery(); + const l = E.getBattery(); // debug: Math.floor(Math.random() * 101); 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; g.setColor(COLORS.white); // 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.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; + } - + old_l = l; //console.log(old_x); g.setColor(levelColor(l)); @@ -64,7 +64,7 @@ } 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}; })();