From 5a3317a324af8b0f929f38c3b84a2cd6a6be97fe Mon Sep 17 00:00:00 2001 From: dapgo Date: Fri, 23 Dec 2022 17:10:14 +0100 Subject: [PATCH] temperature added --- apps/widhwbttm/metadata.json | 2 +- apps/widhwbttm/widhwbttm.wid.js | 55 +++++++++++++++++---------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/apps/widhwbttm/metadata.json b/apps/widhwbttm/metadata.json index a01ffc344..8a6957a46 100644 --- a/apps/widhwbttm/metadata.json +++ b/apps/widhwbttm/metadata.json @@ -3,7 +3,7 @@ "name": "HW stats (Bottom) widget", "shortName": "Digital clock Bottom Widget", "version": "0.03", - "description": "Displays technical info and mem stats in the bottom of the screen (may not be compatible with some apps)", + "description": "Displays technical info, such as model, ver, temperatura or mem stats in the bottom of the screen (may not be compatible with some apps)", "icon": "widhwbttm.png", "type": "widget", "tags": "widget", diff --git a/apps/widhwbttm/widhwbttm.wid.js b/apps/widhwbttm/widhwbttm.wid.js index 57cae8f76..650cc0ff7 100644 --- a/apps/widhwbttm/widhwbttm.wid.js +++ b/apps/widhwbttm/widhwbttm.wid.js @@ -1,5 +1,5 @@ (function() { - let intervalRef = null; + let intervalRef = null; var v_count; // show stats var v_str_hw=new String(); //if (process.env.BOARD=='BANGLEJS'||process.env.BOARD=='EMSCRIPTEN') var v_bfont_size=2; @@ -10,48 +10,49 @@ function draw(){ // if (Bangle.CLOCK) return; //to remove from a clock - if (v_count==0) { v_str_hw=process.env.VERSION.substr(0,6); v_count++; } else if (v_count==1) { v_str_hw=process.env.BOARD.substr(0,3)+".."+process.env.BOARD.substr(process.env.BOARD.length-3,3); v_count++; - } - else if (v_count==2) { + } else if (v_count==2) { v_str_hw="Bat "+E.getBattery()+"%"; v_count++; - } - else { + } + else if (v_count==3 && v_model.substr(0,6)=='BANGLE') { + v_str_hw="Tmp "+E.getTemperature(); + v_count++; + } + else { // text prefix has to be 4char stor=require("Storage").getStats(); - if (v_count==3) { + if (v_count==4) { v_str_hw="Fre "+process.memory().free; //+"/"+process.memory().total; v_count++; } - else if (v_count==4) { - v_str_hw="Sto "+stor.freeBytes; - v_count++; - } else if (v_count==5) { - v_str_hw="Tra "+stor.trashBytes; - v_count++; - } else if (v_count==6) { + else if (v_count==5) { + v_str_hw="Sto "+stor.freeBytes; + v_count++; + } else if (v_count==6) { + v_str_hw="Tra "+stor.trashBytes; + v_count++; + } else if (v_count==7) { v_str_hw="Fil "+stor.fileCount; v_count=0; - } - // 4 char are prefix - if (v_str_hw.length>7) { - //replace 3 digits by k - //substring betw x and y - v_str_hw=v_str_hw.substr(0,v_str_hw.length-3)+"k"; - } - } //end else storage - g.reset().setColor(v_color).setFont("6x8",v_bfont_size).setFontAlign(-1, 0); - //clean a longer previous string, care with br widgets - g.drawString(" ", this.x, this.y+11, true); - g.drawString(v_str_hw, this.x, this.y+11, true); - } //end draw + } + // 4 char are prefix + if (v_str_hw.length>7) { + //replace 3 digits by k + v_str_hw=v_str_hw.substr(0,v_str_hw.length-3)+"k"; + } + } //end else storage + g.reset().setColor(v_color).setFont("6x8",v_bfont_size).setFontAlign(-1, 0); + //clean a longer previous string, care with br widgets + g.drawString(" ", this.x, this.y+11, true); + g.drawString(v_str_hw, this.x, this.y+11, true); + } //end draw WIDGETS["wdhwbttm"]={area:"bl",width:100,draw:draw}; if (Bangle.isLCDOn) intervalRef = setInterval(()=>WIDGETS["wdhwbttm"].draw(), 10*1000);