RAM widget

pull/309/head
Gordon Williams 2020-04-15 14:31:45 +01:00
parent a8f1aabbee
commit 9ccba22694
4 changed files with 36 additions and 0 deletions

View File

@ -363,6 +363,18 @@
{"name":"widbt.wid.js","url":"widget.js"}
]
},
{ "id": "widram",
"name": "RAM Widget",
"shortName":"RAM Widget",
"icon": "widget.png",
"version":"0.01",
"description": "Display your Bangle's available RAM percentage in a widget",
"tags": "widget",
"type": "widget",
"storage": [
{"name":"widram.wid.js","url":"widget.js"}
]
},
{ "id": "hrm",
"name": "Heart Rate Monitor",
"icon": "heartrate.png",

1
apps/widram/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New Widget!

23
apps/widram/widget.js Normal file
View File

@ -0,0 +1,23 @@
(() => {
function draw() {
g.reset();
var m = process.memory();
var pc = 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*/);
}
var ramInterval;
Bangle.on('lcdPower', function(on) {
if (on) {
WIDGETS["ram"].draw();
if (!ramInterval) ramInterval = setInterval(()=>WIDGETS["ram"].draw(), 10000);
} else {
if (ramInterval) {
clearInterval(ramInterval);
ramInterval = undefined;
}
}
});
WIDGETS["ram"]={area:"tl",width: 24,draw:draw};
})()

BIN
apps/widram/widget.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B