widminbate 0.05: Fix broken fork which removed the `update` function

pull/3057/head
Gordon Williams 2023-10-17 11:43:22 +01:00
parent 07fa23ee25
commit d13c084cc9
3 changed files with 8 additions and 6 deletions

View File

@ -3,3 +3,4 @@
0.03: Do not clear outside of widget bar
0.04: Fork `widminbat`->`widminbate`. Only use the system theme foreground
colour.
0.05: Fix broken fork which removed the `update` function

View File

@ -1,7 +1,7 @@
{ "id": "widminbate",
"name": "Extra Minimal Battery",
"shortName":"ExtraMinBat",
"version":"0.04",
"version":"0.05",
"description": "An extra minimal (only use system theme foreground colour) version of the battery widget that only appears if the battery is running low (below 30%)",
"icon": "widget.png",
"type": "widget",

View File

@ -1,7 +1,7 @@
(()=>{
function getWidth() {
{
let getWidth = function() {
return E.getBattery() <= 30 || Bangle.isCharging() ? 40 : 0;
}
};
WIDGETS.minbate={area:"tr",width:getWidth(),draw:function() {
if(this.width < 40) return;
var s = 39;
@ -12,6 +12,7 @@
clearRect(x,y,x+s,y+23).
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).//border
fillRect(x+4,y+6,x+4+barWidth,y+17);//indicator bar
},update: function() {
var newWidth = getWidth();
if(newWidth != this.width) {
this.width = newWidth;
@ -22,7 +23,7 @@
}};
setInterval(()=>{
var widget = WIDGETS.minbate;
if(widget) {widget.update();}
if(widget) widget.update();
}, 10*60*1000);
Bangle.on('charging', () => WIDGETS.minbate.update());
})();
}