From a44d542053941c7bb588e3d444aeb02ad6aba676 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Tue, 30 Nov 2021 22:30:28 +0100 Subject: [PATCH] widbatpc: Fix drawing the bar when charging --- apps.json | 2 +- apps/widbatpc/ChangeLog | 1 + apps/widbatpc/README.md | 4 ++-- apps/widbatpc/widget.js | 16 ++++++++-------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps.json b/apps.json index 2e338a432..351d03bd8 100644 --- a/apps.json +++ b/apps.json @@ -872,7 +872,7 @@ "id": "widbatpc", "name": "Battery Level Widget (with percentage)", "shortName": "Battery Widget", - "version": "0.13", + "version": "0.14", "description": "Show the current battery level and charging status in the top right of the clock, with charge percentage", "icon": "widget.png", "type": "widget", diff --git a/apps/widbatpc/ChangeLog b/apps/widbatpc/ChangeLog index 09e4fabf4..99822b5a9 100644 --- a/apps/widbatpc/ChangeLog +++ b/apps/widbatpc/ChangeLog @@ -10,3 +10,4 @@ 0.11: Don't overwrite existing settings on app update 0.12: Fixed for Bangle 2 0.13: Fillbar setting added, see README +0.14: Fix drawing the bar when charging diff --git a/apps/widbatpc/README.md b/apps/widbatpc/README.md index c75154f72..48c6070f4 100644 --- a/apps/widbatpc/README.md +++ b/apps/widbatpc/README.md @@ -5,12 +5,12 @@ Show the current battery level and charging status in the top right of the clock Works with Bangle 1 and Bangle 2 When the fillbar setting is on the level colour will fill the entire -bar. This makes for an easier to read dsiplay when the charge is +bar. This makes for an easier to read display when the charge is below 50%. ![](widbatpc.full.jpg) -When the fillbar setting is off the level colour will follow the battry percentage +When the fillbar setting is off the level colour will follow the battery percentage ![](widbatpc.part.jpg) diff --git a/apps/widbatpc/widget.js b/apps/widbatpc/widget.js index caecf8ae4..3e5ff47b4 100644 --- a/apps/widbatpc/widget.js +++ b/apps/widbatpc/widget.js @@ -79,20 +79,20 @@ // else... var s = 39; var x = this.x, y = this.y; - const l = E.getBattery(); - let xl = x+4+l*(s-12)/100; + const l = E.getBattery(), + c = levelColor(l); - // show bar full in the level color, as you cant see the color if the bar is too small - if (setting('fillbar')) - xl = x+4+100*(s-12)/100; - - c = levelColor(l); - if (Bangle.isCharging() && setting('charger')) { g.setColor(chargerColor()).drawImage(atob( "DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y); x+=16; } + + let xl = x+4+l*(s-12)/100; + // show bar full in the level color, as you can't see the color if the bar is too small + if (setting('fillbar')) + xl = x+4+100*(s-12)/100; + g.setColor(g.theme.fg); g.fillRect(x,y+2,x+s-4,y+21); g.clearRect(x+2,y+4,x+s-6,y+19);