Update widget.js

pull/1349/head
Hilmar Strauch 2022-01-26 14:29:53 +01:00 committed by GitHub
parent 88ac23b657
commit 947f403ba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -1,11 +1,15 @@
(() => {
function draw() {
BANGLEJS2 = process.env.HWVERSION==2;
g.reset();
var m = process.memory();
var pc = Math.round(m.usage*100/m.total);
var percent = Math.round(m.usage*100/m.total);
g.drawImage(atob("BwgBqgP////AVQ=="), this.x+(24-7)/2, this.y+4);
g.setColor(pc>70 ? "#ff0000" : (pc>50 ? "#ffff00" : "#ffffff"));
g.setFont("6x8").setFontAlign(0,0).drawString(pc+"%", this.x+12, this.y+20, true/*solid*/);
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*/);
}
var ramInterval;
Bangle.on('lcdPower', function(on) {
@ -20,4 +24,4 @@
}
});
WIDGETS["ram"]={area:"tl",width: 24,draw:draw};
})()
})();