From 2538d417ad9336f22410628e2c4e0dd1f3545036 Mon Sep 17 00:00:00 2001 From: KungPhoo Date: Wed, 8 Feb 2023 13:59:38 +0100 Subject: [PATCH] Change colour Changes the to yellow on < 50% and red on < 20% battery percentage. --- apps/widbat/widget.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/widbat/widget.js b/apps/widbat/widget.js index a8a0c5382..7fce16335 100644 --- a/apps/widbat/widget.js +++ b/apps/widbat/widget.js @@ -31,7 +31,11 @@ x+=16; } g.setColor(g.theme.fg).fillRect(x,y+2,x+s-4,y+21).clearRect(x+2,y+4,x+s-6,y+19).fillRect(x+s-3,y+10,x+s,y+14); - g.setColor("#0f0").fillRect(x+4,y+6,x+4+E.getBattery()*(s-12)/100,y+17); + var battery = E.getBattery(); + if(battery < 20) {g.setColor("#f00");} + else if (battery < 50) {g.setColor("#ff0");} + else {g.setColor("#0f0");} + g.fillRect(x+4,y+6,x+4+battery*(s-12)/100,y+17); }}; setWidth(); })()