From 09fc1f7d3e9bd8652d410c83b27d23e88609caec Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Thu, 2 Apr 2020 00:16:46 +0200 Subject: [PATCH] Battery Widget: Show battery percentage as text --- apps.json | 2 +- apps/widbat/ChangeLog | 1 + apps/widbat/widget.js | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps.json b/apps.json index a022d590b..032b0b7d7 100644 --- a/apps.json +++ b/apps.json @@ -326,7 +326,7 @@ { "id": "widbat", "name": "Battery Level Widget", "icon": "widget.png", - "version":"0.05", + "version":"0.06", "description": "Show the current battery level and charging status in the top right of the clock", "tags": "widget,battery", "type":"widget", diff --git a/apps/widbat/ChangeLog b/apps/widbat/ChangeLog index 38c3b767e..55464e390 100644 --- a/apps/widbat/ChangeLog +++ b/apps/widbat/ChangeLog @@ -2,3 +2,4 @@ 0.03: Tweaks for variable size widget system 0.04: Ensure redrawing works with variable size widget system 0.05: Change color depending on battery level +0.06: Show battery percentage as text diff --git a/apps/widbat/widget.js b/apps/widbat/widget.js index e1cc8baff..7100dc111 100644 --- a/apps/widbat/widget.js +++ b/apps/widbat/widget.js @@ -24,6 +24,15 @@ function draw() { g.fillRect(x+s-3,y+10,x+s,y+14); g.setColor(c).fillRect(x+4,y+6,x+4+l*(s-12)/100,y+17); g.setColor(-1); + g.setFontAlign(-1,-1); + if (l >= 100) { + g.setFont('4x6', 2); + g.drawString(l, x + 6, y + 7); + } else { + if (l < 10) x+=6; + g.setFont('6x8', 2); + g.drawString(l, x + 6, y + 4); + } } Bangle.on('charging',function(charging) { if(charging) Bangle.buzz();