powermanager - Let letter in widget denote most expensive active sensor

master
Martin Boonk 2023-02-20 20:05:28 +01:00
parent ae81d93666
commit b8792ade17
1 changed files with 17 additions and 4 deletions

View File

@ -30,10 +30,21 @@ currently-running apps */
g.clearRect(this.x, this.y, this.x + 24, this.y + 24); g.clearRect(this.x, this.y, this.x + 24, this.y + 24);
let current = APPROX_IDLE; let current = APPROX_IDLE;
if (Bangle.isGPSOn()) current += APPROX_GPS; let mostExpensive = "P";
if (Bangle.isHRMOn()) current += APPROX_HRM;
if (!Bangle.isLocked()) current += APPROX_TOUCH + brightness(); if (!Bangle.isLocked()) current += APPROX_TOUCH + brightness();
if (Bangle.isCompassOn()) current += APPROX_COMPASS; if (Bangle.isCompassOn()) {
current += APPROX_COMPASS;
mostExpensive = "C";
}
if (Bangle.isHRMOn()) {
current += APPROX_HRM;
mostExpensive = "H";
}
if (Bangle.isGPSOn()) {
current += APPROX_GPS;
mostExpensive = "G";
}
current = current / MAX; current = current / MAX;
@ -41,7 +52,7 @@ currently-running apps */
g.setFont6x15(); g.setFont6x15();
g.setFontAlign(0, 0); g.setFontAlign(0, 0);
g.drawString("P", this.x + 12, this.y + 15); g.drawString(mostExpensive, this.x + 12, this.y + 15);
let end = 135 + (current * (405 - 135)); let end = 135 + (current * (405 - 135));
g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0")); g.setColor(current > 0.7 ? "#f00" : (current > 0.3 ? "#ff0" : "#0f0"));
@ -63,6 +74,8 @@ currently-running apps */
draw: draw draw: draw
}; };
Bangle.on("lock", draw);
// conserve memory // conserve memory
delete settings; delete settings;
})(); })();