diff --git a/apps/hwid_a_battery_widget/ChangeLog b/apps/hwid_a_battery_widget/ChangeLog index 9d5ee1264..da289abff 100644 --- a/apps/hwid_a_battery_widget/ChangeLog +++ b/apps/hwid_a_battery_widget/ChangeLog @@ -4,4 +4,4 @@ 0.04: Increase screen update rate when charging 0.05: Deleting Background - making Font larger 0.06: Fixing refresh issues -0.07 \ No newline at end of file +0.07: Fixed position after unlocking \ No newline at end of file diff --git a/apps/hwid_a_battery_widget/README.md b/apps/hwid_a_battery_widget/README.md index 638272b3f..db105635a 100644 --- a/apps/hwid_a_battery_widget/README.md +++ b/apps/hwid_a_battery_widget/README.md @@ -1,4 +1,4 @@ -# A Battery Widget (with percentage) +# A Battery Widget (with percentage) - Mod by Hank Show the current battery level and charging status in the top right of the clock, with charge percentage diff --git a/apps/hwid_a_battery_widget/widget.js b/apps/hwid_a_battery_widget/widget.js index 708e8cbbf..ad9bb3c46 100644 --- a/apps/hwid_a_battery_widget/widget.js +++ b/apps/hwid_a_battery_widget/widget.js @@ -3,6 +3,10 @@ const intervalHigh = 2000; // update time when charging var old_l; + old_x = this.x; + old_y = this.y; + + let COLORS = { 'white': g.theme.dark ? "#000" : "#fff", 'black': g.theme.dark ? "#fff" : "#000", @@ -19,7 +23,9 @@ function draw() { var s = 29; - var x = this.x, y = this.y; + var x = this.x; + var y = this.y; + const l = E.getBattery(); let xl = x+4+l*(s-12)/100; if (l != old_l){ // Delete the old value from screen @@ -30,7 +36,7 @@ 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.drawString(old_l, old_x + 14, old_y + 10); //debug g.fillRect(x+4,y+14+3,xl_old,y+16+3); // charging bar } @@ -42,11 +48,15 @@ g.setFontAlign(0,0); g.setFont('Vector',16); g.drawString(l, x + 14, y + 10); + g.drawString(x, 110, 5); 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);