widbatpc: Only redraw when values change
parent
fb1518f6b8
commit
b8e0222315
|
|
@ -15,3 +15,4 @@
|
||||||
0.16: Increase screen update rate when charging
|
0.16: Increase screen update rate when charging
|
||||||
0.17: Add option 'Remove Jitter'='Drop only' to prevent percentage from getting up again when not charging
|
0.17: Add option 'Remove Jitter'='Drop only' to prevent percentage from getting up again when not charging
|
||||||
Add option to disable vibration when charger connects
|
Add option to disable vibration when charger connects
|
||||||
|
0.18: Only redraw when values change
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "widbatpc",
|
"id": "widbatpc",
|
||||||
"name": "Battery Level Widget (with percentage)",
|
"name": "Battery Level Widget (with percentage)",
|
||||||
"shortName": "Battery Widget",
|
"shortName": "Battery Widget",
|
||||||
"version": "0.17",
|
"version": "0.18",
|
||||||
"description": "Show the current battery level and charging status in the top right of the clock, with charge percentage",
|
"description": "Show the current battery level and charging status in the top right of the clock, with charge percentage",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw(fromIntervall) {
|
||||||
// if hidden, don't draw
|
// if hidden, don't draw
|
||||||
if (!WIDGETS["batpc"].width) return;
|
if (!WIDGETS["batpc"].width) return;
|
||||||
// else...
|
// else...
|
||||||
|
|
@ -103,6 +103,14 @@
|
||||||
l = prevMin;
|
l = prevMin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fromIntervall === true && this.prevLevel === l && this.prevCharging === Bangle.isCharging()) {
|
||||||
|
return; // unchanged, do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
this.prevLevel = l;
|
||||||
|
this.prevCharging = Bangle.isCharging();
|
||||||
|
|
||||||
const c = levelColor(l);
|
const c = levelColor(l);
|
||||||
|
|
||||||
if (Bangle.isCharging() && setting('charger')) {
|
if (Bangle.isCharging() && setting('charger')) {
|
||||||
|
|
@ -149,6 +157,8 @@
|
||||||
// can affect the width and mess with the whole widget layout
|
// can affect the width and mess with the whole widget layout
|
||||||
setWidth();
|
setWidth();
|
||||||
g.clear();
|
g.clear();
|
||||||
|
WIDGETS["batpc"].prevLevel = undefined;
|
||||||
|
WIDGETS["batpc"].prevCharging = undefined;
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +183,7 @@
|
||||||
if (on) update();
|
if (on) update();
|
||||||
});
|
});
|
||||||
|
|
||||||
var id = setInterval(()=>WIDGETS["batpc"].draw(), intervalLow);
|
var id = setInterval(()=>WIDGETS["batpc"].draw(true), intervalLow);
|
||||||
|
|
||||||
WIDGETS["batpc"]={area:"tr",width:40,draw:draw,reload:reload};
|
WIDGETS["batpc"]={area:"tr",width:40,draw:draw,reload:reload};
|
||||||
setWidth();
|
setWidth();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue