diff --git a/apps/hwid_a_battery_widget/Automatisch beibehalten von Corel/widget.png b/apps/hwid_a_battery_widget/Automatisch beibehalten von Corel/widget.png new file mode 100644 index 000000000..868628b60 Binary files /dev/null and b/apps/hwid_a_battery_widget/Automatisch beibehalten von Corel/widget.png differ diff --git a/apps/hwid_a_battery_widget/ChangeLog b/apps/hwid_a_battery_widget/ChangeLog new file mode 100644 index 000000000..84cbad8ad --- /dev/null +++ b/apps/hwid_a_battery_widget/ChangeLog @@ -0,0 +1,5 @@ +0.01: Release for Bangle 2 (2021/11/18) +0.02: Internal id update to wid_* as per Gordon's request (2021/11/21) +0.03: Support dark themes +0.04: Increase screen update rate when charging +0.05: Deleting Background - making Font larger \ No newline at end of file diff --git a/apps/hwid_a_battery_widget/README.md b/apps/hwid_a_battery_widget/README.md new file mode 100644 index 000000000..638272b3f --- /dev/null +++ b/apps/hwid_a_battery_widget/README.md @@ -0,0 +1,15 @@ +# A Battery Widget (with percentage) + +Show the current battery level and charging status in the top right of the clock, with charge percentage + +* Works with Bangle 2 +* Simple design, no settings + * Red when the batterly level is below 30% + * Blue when charging +* 40 pixels wide + +![](a_battery_widget-pic.jpg) + +## Creator +[@alainsaas](https://github.com/alainsaas) +Mod by Hank diff --git a/apps/hwid_a_battery_widget/h_battery_widget-pic.jpg b/apps/hwid_a_battery_widget/h_battery_widget-pic.jpg new file mode 100644 index 000000000..9d9a4decc Binary files /dev/null and b/apps/hwid_a_battery_widget/h_battery_widget-pic.jpg differ diff --git a/apps/hwid_a_battery_widget/metadata.json b/apps/hwid_a_battery_widget/metadata.json new file mode 100644 index 000000000..7fdd2907a --- /dev/null +++ b/apps/hwid_a_battery_widget/metadata.json @@ -0,0 +1,15 @@ +{ + "id": "hwid_a_battery_widget", + "name": "A Battery Widget (with percentage) - Hanks Mod", + "shortName":"H Battery Widget", + "icon": "widget.png", + "version":"0.04", + "type": "widget", + "supports": ["BANGLEJS", "BANGLEJS2"], + "readme": "README.md", + "description": "Simple and slim battery widget with charge status and percentage", + "tags": "widget,battery", + "storage": [ + {"name":"hwid_a_battery_widget.wid.js","url":"widget.js"} + ] +} diff --git a/apps/hwid_a_battery_widget/widget.js b/apps/hwid_a_battery_widget/widget.js new file mode 100644 index 000000000..0929dea41 --- /dev/null +++ b/apps/hwid_a_battery_widget/widget.js @@ -0,0 +1,56 @@ +(function(){ + const intervalLow = 60000; // update time when not charging + const intervalHigh = 2000; // update time when charging + + let COLORS = { + 'white': g.theme.dark ? "#000" : "#fff", + 'black': g.theme.dark ? "#fff" : "#000", + 'charging': "#08f", + 'high': g.theme.dark ? "#fff" : "#000", + 'low': "#f00", + }; + + const levelColor = (l) => { + if (Bangle.isCharging()) return COLORS.charging; + if (l >= 30) return COLORS.high; + return COLORS.low; + }; + + function draw() { + var s = 29; + var x = this.x, y = this.y; + + const l = E.getBattery(); + + let xl = x+4+l*(s-12)/100; + + g.setColor(COLORS.white); + // g.fillRect(x+2,y+5,x+s-6,y+18); + + g.fillRect(x,y,xl+4,y+16+3); //Clear + + g.setColor(levelColor(l)); + // g.fillRect(x+1,y+3,x+s-5,y+4); + // g.fillRect(x+1,y+19,x+s-5,y+20); + // g.fillRect(x,y+4,x+1,y+19); + // g.fillRect(x+s-5,y+4,x+s-4,y+19); + //g.fillRect(x+s-3,y+8,x+s-2,y+16); // tip of the battery + g.fillRect(x+4,y+14+3,xl,y+16+3); // charging bar + + g.fillRect((x+4+100*(s-12)/100)-1,y+14+3,x+4+100*(s-12)/100,y+16+3); // charging bar full + + g.setColor(COLORS.black); + g.setFontAlign(0,0); + g.setFont('Vector',16); + g.drawString(l, x + 14, y + 10); + + if (Bangle.isCharging()) changeInterval(id, intervalHigh); + else changeInterval(id, intervalLow); + } + + + Bangle.on('charging',function(charging) { draw(); }); + var id = setInterval(()=>WIDGETS["wid_a_battery_widget"].draw(), intervalLow); + + WIDGETS["wid_a_battery_widget"]={area:"tr",width:30,draw:draw}; +})(); diff --git a/apps/hwid_a_battery_widget/widget.png b/apps/hwid_a_battery_widget/widget.png new file mode 100644 index 000000000..b9c9594b1 Binary files /dev/null and b/apps/hwid_a_battery_widget/widget.png differ