BangleApps/apps/widChargingStatus/widget.js

30 lines
638 B
JavaScript
Raw Normal View History

(() => {
2021-12-04 21:26:55 +00:00
const icon = require("heatshrink").decompress(atob("kEggIEBoAIC4ADFgIDCgYDDwADBg4DGh4DGj4DCn4DD/4gBv4DEBgP//4PBAYUB//+GQIDE/hDCAYf4AY3wAYXgAYxfHIYQDEOQUCAQI"));
2021-12-04 21:22:22 +00:00
function draw() {
g.reset();
2021-12-04 21:37:16 +00:00
if (Bangle.isCharging()) {
g.setColor("#FD0");
g.drawImage(icon, this.x, this.y + 1, {
scale: 0.6875
});
}
}
WIDGETS.chargingStatus = {
area: 'tr',
2021-12-04 21:37:16 +00:00
width: 22,
draw: draw,
};
2021-12-04 21:37:16 +00:00
Bangle.on('charging', (charging) => {
if (charging) {
Bangle.buzz();
WIDGETS.chargingStatus.width = 22;
} else {
WIDGETS.chargingStatus.width = 0;
}
Bangle.drawWidgets(); // re-layout widgets
g.flip();
});
})();