mirror of https://github.com/espruino/BangleApps
widminbate 0.05: Fix broken fork which removed the `update` function
parent
07fa23ee25
commit
d13c084cc9
|
@ -3,3 +3,4 @@
|
||||||
0.03: Do not clear outside of widget bar
|
0.03: Do not clear outside of widget bar
|
||||||
0.04: Fork `widminbat`->`widminbate`. Only use the system theme foreground
|
0.04: Fork `widminbat`->`widminbate`. Only use the system theme foreground
|
||||||
colour.
|
colour.
|
||||||
|
0.05: Fix broken fork which removed the `update` function
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "widminbate",
|
{ "id": "widminbate",
|
||||||
"name": "Extra Minimal Battery",
|
"name": "Extra Minimal Battery",
|
||||||
"shortName":"ExtraMinBat",
|
"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%)",
|
"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",
|
"icon": "widget.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(()=>{
|
{
|
||||||
function getWidth() {
|
let getWidth = function() {
|
||||||
return E.getBattery() <= 30 || Bangle.isCharging() ? 40 : 0;
|
return E.getBattery() <= 30 || Bangle.isCharging() ? 40 : 0;
|
||||||
}
|
};
|
||||||
WIDGETS.minbate={area:"tr",width:getWidth(),draw:function() {
|
WIDGETS.minbate={area:"tr",width:getWidth(),draw:function() {
|
||||||
if(this.width < 40) return;
|
if(this.width < 40) return;
|
||||||
var s = 39;
|
var s = 39;
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
clearRect(x,y,x+s,y+23).
|
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
|
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
|
fillRect(x+4,y+6,x+4+barWidth,y+17);//indicator bar
|
||||||
|
},update: function() {
|
||||||
var newWidth = getWidth();
|
var newWidth = getWidth();
|
||||||
if(newWidth != this.width) {
|
if(newWidth != this.width) {
|
||||||
this.width = newWidth;
|
this.width = newWidth;
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
}};
|
}};
|
||||||
setInterval(()=>{
|
setInterval(()=>{
|
||||||
var widget = WIDGETS.minbate;
|
var widget = WIDGETS.minbate;
|
||||||
if(widget) {widget.update();}
|
if(widget) widget.update();
|
||||||
}, 10*60*1000);
|
}, 10*60*1000);
|
||||||
Bangle.on('charging', () => WIDGETS.minbate.update());
|
Bangle.on('charging', () => WIDGETS.minbate.update());
|
||||||
})();
|
}
|
Loading…
Reference in New Issue