Merge pull request #1349 from HilmarSt/master

RAM Widget: Now also visible on Bangle.js 2
master
Gordon Williams 2022-01-26 14:02:14 +00:00 committed by GitHub
commit d46f9bd1ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -1 +1,2 @@
0.01: New Widget! 0.01: New Widget!
0.02: Now also visible on Bangle.js 2

View File

@ -2,8 +2,8 @@
"id": "widram", "id": "widram",
"name": "RAM Widget", "name": "RAM Widget",
"shortName": "RAM Widget", "shortName": "RAM Widget",
"version": "0.01", "version": "0.02",
"description": "Display your Bangle's available RAM percentage in a widget", "description": "Display your Bangle's RAM usage percentage in a widget",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",
"tags": "widget", "tags": "widget",

View File

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