forked from FOSS/BangleApps
widminbate: make monochrome
parent
14ac41c8e6
commit
518009a0a4
|
@ -1,3 +1,5 @@
|
|||
0.01: Initial Version: Display at under 30% battery
|
||||
0.02: Display while charging
|
||||
0.03: Do not clear outside of widget bar
|
||||
0.04: Fork `widminbat`->`widminbate`. Only use the system theme foreground
|
||||
colour.
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{ "id": "widminbat",
|
||||
"name": "Minimal Battery",
|
||||
"shortName":"MinBat",
|
||||
"version":"0.03",
|
||||
"description": "A minimal version of the battery widget that only appears if the battery is running low (below 30%)",
|
||||
{ "id": "widminbate",
|
||||
"name": "Extra Minimal Battery",
|
||||
"shortName":"ExtraMinBat",
|
||||
"version":"0.04",
|
||||
"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",
|
||||
"tags": "widget,battery,minimal",
|
||||
"tags": "widget,battery,minimal,monochrome",
|
||||
"supports" : ["BANGLEJS2", "BANGLEJS"],
|
||||
"storage": [
|
||||
{"name":"widminbat.wid.js","url":"widget.js"}
|
||||
{"name":"widminbate.wid.js","url":"widget.js"}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,18 +2,16 @@
|
|||
function getWidth() {
|
||||
return E.getBattery() <= 30 || Bangle.isCharging() ? 40 : 0;
|
||||
}
|
||||
WIDGETS.minbat={area:"tr",width:getWidth(),draw:function() {
|
||||
WIDGETS.minbate={area:"tr",width:getWidth(),draw:function() {
|
||||
if(this.width < 40) return;
|
||||
var s = 39;
|
||||
var bat = E.getBattery();
|
||||
var x = this.x, y = this.y;
|
||||
g.reset();
|
||||
g.clearRect(x,y,x+s,y+23);
|
||||
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);
|
||||
var barWidth = bat*(s-12)/100;
|
||||
var color = bat < 15 ? "#f00" : (bat <= 30 ? "#f80" : "#0f0");
|
||||
g.setColor(color).fillRect(x+4,y+6,x+4+barWidth,y+17);
|
||||
},update: function() {
|
||||
g.reset().
|
||||
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
|
||||
var newWidth = getWidth();
|
||||
if(newWidth != this.width) {
|
||||
this.width = newWidth;
|
||||
|
@ -23,8 +21,8 @@
|
|||
}
|
||||
}};
|
||||
setInterval(()=>{
|
||||
var widget = WIDGETS.minbat;
|
||||
var widget = WIDGETS.minbate;
|
||||
if(widget) {widget.update();}
|
||||
}, 10*60*1000);
|
||||
Bangle.on('charging', () => WIDGETS.minbat.update());
|
||||
Bangle.on('charging', () => WIDGETS.minbate.update());
|
||||
})();
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in New Issue