forked from FOSS/BangleApps
commit
160a2953ab
|
@ -1 +1,2 @@
|
||||||
|
0.02: Display while charging
|
||||||
0.01: Initial Version: Display at under 30% battery
|
0.01: Initial Version: Display at under 30% battery
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "widminbat",
|
{ "id": "widminbat",
|
||||||
"name": "Minimal Battery",
|
"name": "Minimal Battery",
|
||||||
"shortName":"MinBat",
|
"shortName":"MinBat",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "A minimal version of the battery widget that only appears if the battery is running low (below 30%)",
|
"description": "A minimal 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,6 +1,6 @@
|
||||||
(()=>{
|
(()=>{
|
||||||
function getWidth() {
|
function getWidth() {
|
||||||
return E.getBattery() <= 30 ? 40 : 0;
|
return E.getBattery() <= 30 || Bangle.isCharging() ? 40 : 0;
|
||||||
}
|
}
|
||||||
WIDGETS.minbat={area:"tr",width:getWidth(),draw:function() {
|
WIDGETS.minbat={area:"tr",width:getWidth(),draw:function() {
|
||||||
if(this.width < 40) return;
|
if(this.width < 40) return;
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
g.clearRect(x,y,x+s,y+24);
|
g.clearRect(x,y,x+s,y+24);
|
||||||
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(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 barWidth = bat*(s-12)/100;
|
||||||
var color = bat < 15 ? "#f00" : "#f80";
|
var color = bat < 15 ? "#f00" : (bat <= 30 ? "#f80" : "#0f0");
|
||||||
g.setColor(color).fillRect(x+4,y+6,x+4+barWidth,y+17);
|
g.setColor(color).fillRect(x+4,y+6,x+4+barWidth,y+17);
|
||||||
},update: function() {
|
},update: function() {
|
||||||
var newWidth = getWidth();
|
var newWidth = getWidth();
|
||||||
|
@ -26,4 +26,5 @@
|
||||||
var widget = WIDGETS.minbat;
|
var widget = WIDGETS.minbat;
|
||||||
if(widget) {widget.update();}
|
if(widget) {widget.update();}
|
||||||
}, 10*60*1000);
|
}, 10*60*1000);
|
||||||
|
Bangle.on('charging', () => WIDGETS.minbat.update());
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue