Add setting to hide widget when battery is over 20%.
parent
745e4d38a9
commit
1596b0246b
|
|
@ -11,6 +11,7 @@
|
||||||
'color': COLORS[0],
|
'color': COLORS[0],
|
||||||
'percentage': true,
|
'percentage': true,
|
||||||
'charger': true,
|
'charger': true,
|
||||||
|
'hideifmorethan20pct': false,
|
||||||
}
|
}
|
||||||
// ...and overwrite them with any saved values
|
// ...and overwrite them with any saved values
|
||||||
// This way saved values are preserved if a new version adds more settings
|
// This way saved values are preserved if a new version adds more settings
|
||||||
|
|
@ -51,7 +52,12 @@
|
||||||
const newIndex = (oldIndex + 1) % COLORS.length
|
const newIndex = (oldIndex + 1) % COLORS.length
|
||||||
s.color = COLORS[newIndex]
|
s.color = COLORS[newIndex]
|
||||||
save('color')(s.color)
|
save('color')(s.color)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
'Hide when \> 20\%': {
|
||||||
|
value: s.hideifmorethan20pct,
|
||||||
|
format: onOffFormat,
|
||||||
|
onchange: save('hideifmorethan20pct'),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
E.showMenu(menu)
|
E.showMenu(menu)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
{"color":"By Level","percentage":true,"charger":true,"hideifmorethan20pct":false}
|
||||||
|
|
@ -3,6 +3,7 @@ const DEFAULTS = {
|
||||||
'color': 'By Level',
|
'color': 'By Level',
|
||||||
'percentage': true,
|
'percentage': true,
|
||||||
'charger': true,
|
'charger': true,
|
||||||
|
'hideifmorethan20pct': false,
|
||||||
}
|
}
|
||||||
const COLORS = {
|
const COLORS = {
|
||||||
'white': -1,
|
'white': -1,
|
||||||
|
|
@ -53,8 +54,16 @@ function setWidth() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function draw() {
|
function draw() {
|
||||||
|
|
||||||
var s = 39;
|
var s = 39;
|
||||||
var x = this.x, y = this.y;
|
var x = this.x, y = this.y;
|
||||||
|
const l = E.getBattery(),
|
||||||
|
c = levelColor(l);
|
||||||
|
const xl = x+4+l*(s-12)/100
|
||||||
|
|
||||||
|
if(!Bangle.isCharging() && setting('hideifmorethan20pct') && l > 20){
|
||||||
|
return;}
|
||||||
|
|
||||||
if (Bangle.isCharging() && setting('charger')) {
|
if (Bangle.isCharging() && setting('charger')) {
|
||||||
g.setColor(chargerColor()).drawImage(atob(
|
g.setColor(chargerColor()).drawImage(atob(
|
||||||
"DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y);
|
"DhgBHOBzgc4HOP////////////////////3/4HgB4AeAHgB4AeAHgB4AeAHg"),x,y);
|
||||||
|
|
@ -64,9 +73,7 @@ function draw() {
|
||||||
g.fillRect(x,y+2,x+s-4,y+21);
|
g.fillRect(x,y+2,x+s-4,y+21);
|
||||||
g.clearRect(x+2,y+4,x+s-6,y+19);
|
g.clearRect(x+2,y+4,x+s-6,y+19);
|
||||||
g.fillRect(x+s-3,y+10,x+s,y+14);
|
g.fillRect(x+s-3,y+10,x+s,y+14);
|
||||||
const l = E.getBattery(),
|
|
||||||
c = levelColor(l);
|
|
||||||
const xl = x+4+l*(s-12)/100
|
|
||||||
g.setColor(c).fillRect(x+4,y+6,xl,y+17);
|
g.setColor(c).fillRect(x+4,y+6,xl,y+17);
|
||||||
g.setColor(-1);
|
g.setColor(-1);
|
||||||
if (!setting('percentage')) {
|
if (!setting('percentage')) {
|
||||||
Loading…
Reference in New Issue