2020-04-15 13:31:45 +00:00
|
|
|
(() => {
|
|
|
|
function draw() {
|
2022-01-26 13:29:53 +00:00
|
|
|
BANGLEJS2 = process.env.HWVERSION==2;
|
2020-04-15 13:31:45 +00:00
|
|
|
g.reset();
|
2020-05-23 20:51:24 +00:00
|
|
|
var m = process.memory();
|
2022-01-26 13:29:53 +00:00
|
|
|
var percent = Math.round(m.usage*100/m.total);
|
2020-04-15 13:31:45 +00:00
|
|
|
g.drawImage(atob("BwgBqgP////AVQ=="), this.x+(24-7)/2, this.y+4);
|
2022-01-26 13:29:53 +00:00
|
|
|
if (!BANGLEJS2)
|
|
|
|
g.setColor(percent>70 ? "#ff0000" : (percent>50 ? "#ffff00" : "#ffffff"));
|
|
|
|
else
|
|
|
|
g.setColor(percent>70 ? "#0f0" : (percent>50 ? "#00f" : "#f00"));
|
|
|
|
g.setFont("6x8").setFontAlign(0,0).drawString(percent+"%", this.x+12, this.y+20, true/*solid*/);
|
2020-04-15 13:31:45 +00:00
|
|
|
}
|
|
|
|
var ramInterval;
|
|
|
|
Bangle.on('lcdPower', function(on) {
|
|
|
|
if (on) {
|
2020-05-23 21:32:33 +00:00
|
|
|
WIDGETS["ram"].draw();
|
|
|
|
if (!ramInterval) ramInterval = setInterval(()=>WIDGETS["ram"].draw(), 10000);
|
|
|
|
} else {
|
|
|
|
if (ramInterval) {
|
|
|
|
clearInterval(ramInterval);
|
|
|
|
ramInterval = undefined;
|
|
|
|
}
|
|
|
|
}
|
2020-04-15 13:31:45 +00:00
|
|
|
});
|
|
|
|
WIDGETS["ram"]={area:"tl",width: 24,draw:draw};
|
2022-01-26 13:29:53 +00:00
|
|
|
})();
|