2021-12-04 19:30:13 +00:00
|
|
|
(() => {
|
2021-12-08 19:22:39 +00:00
|
|
|
const icon = require('heatshrink').decompress(
|
|
|
|
atob(
|
|
|
|
'ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
const iconWidth = 18;
|
2021-12-04 21:22:22 +00:00
|
|
|
|
2023-02-25 21:58:53 +00:00
|
|
|
function draw(this: { x?: number; y?: number }) {
|
2021-12-08 19:22:39 +00:00
|
|
|
g.reset();
|
|
|
|
if (Bangle.isCharging()) {
|
|
|
|
g.setColor('#FD0');
|
2023-02-25 21:58:53 +00:00
|
|
|
g.drawImage(icon, this.x! + 1, this.y! + 1, {
|
2021-12-08 19:22:39 +00:00
|
|
|
scale: 0.6875,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-12-04 19:30:13 +00:00
|
|
|
|
2024-05-04 21:21:43 +00:00
|
|
|
WIDGETS["chargingStatus"] = {
|
2021-12-08 19:22:39 +00:00
|
|
|
area: 'tr',
|
|
|
|
width: Bangle.isCharging() ? iconWidth : 0,
|
2021-12-10 21:32:36 +00:00
|
|
|
draw: draw,
|
2021-12-08 19:22:39 +00:00
|
|
|
};
|
2021-12-04 19:30:13 +00:00
|
|
|
|
2021-12-08 19:22:39 +00:00
|
|
|
Bangle.on('charging', (charging) => {
|
2024-05-04 21:21:43 +00:00
|
|
|
const widget = WIDGETS["chargingStatus"];
|
2021-12-10 20:36:42 +00:00
|
|
|
if (widget) {
|
|
|
|
if (charging) {
|
|
|
|
Bangle.buzz();
|
|
|
|
widget.width = iconWidth;
|
|
|
|
} else {
|
2024-04-27 15:19:05 +00:00
|
|
|
Promise.resolve().then(() => require("buzz").pattern("..;"));
|
2021-12-10 20:36:42 +00:00
|
|
|
widget.width = 0;
|
|
|
|
}
|
|
|
|
Bangle.drawWidgets(); // re-layout widgets
|
|
|
|
g.flip();
|
2021-12-08 19:22:39 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|