1
0
Fork 0

corrections suggested on #2404

master
dapgo 2022-12-15 23:59:52 +01:00
parent 316631cccc
commit 650d04ab99
5 changed files with 45 additions and 38 deletions

View File

@ -23,7 +23,7 @@ if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') {
v_font_size2=60;
//g.setColor("#0ff"); //light color
}else{
v_font_size1=10;
v_font_size1=11;
v_font_size2=40;
//g.setColor("#000"); //black or dark
}
@ -35,8 +35,8 @@ function onTemperature(v_temp) {
g.setFontVector(v_font_size1).setFontAlign(0,0);
var x = (rect.x+rect.x2)/2;
var y = (rect.y+rect.y2)/2 + 20;
g.drawString("Records:"+v_saved_entries, x, rect.y+30);
g.drawString("Temperature:", x, rect.y+35+v_font_size1);
g.drawString("Records: "+v_saved_entries, x, rect.y+35);
g.drawString("Temperature:", x, rect.y+37+v_font_size1);
//dynamic font (g.getWidth() > 200 ? 60 : 40)
g.setFontVector(v_font_size2).setFontAlign(0,0);
// Avg of temperature readings
@ -48,7 +48,8 @@ function onTemperature(v_temp) {
lastMeasure=avrTemp.toString();
if (lastMeasure.length>4) lastMeasure=lastMeasure.substr(0,4);
//DRAW temperature in the center
g.drawString(v_temp+v_t_symbol, x, y);
g.drawString(" ", x-20, y);
g.drawString(v_temp+v_t_symbol, x-20, y);
g.flip();
}
// from: BJS2 pressure sensor, BJS1 inbuilt thermistor
@ -65,7 +66,7 @@ function saveToFile() {
//input global vars: lastMeasure
var a=new Date();
var strlastSaveTime=new String();
var strlastSaveTime=a.toISOString();
strlastSaveTime=a.toISOString();
//strlastSaveTime=strlastSaveTime.concat(a.getFullYear(),a.getMonth()+1,a.getDate(),a.getHours(),a.getMinutes());;
if (v_mode_debug==1) console.log("saving="+strlastSaveTime+","+lastMeasure);
@ -109,7 +110,7 @@ function introPage(){
g.drawString("Save to file: "+v_saveToFile, x, y+ ((v_font_size1*1)+2) );
g.drawString("Save freq(ms):"+saveFreq, x, y+((v_font_size1*2)+2) );
fr=require("Storage").read(filename+"\1");//suffix required
if (fr) g.drawString("Current filesize:"+fr.length.toString()+"kb", x, y+((v_font_size1*3)+2) )
if (fr) g.drawString("Current filesize:"+fr.length.toString()+"kb", x, y+((v_font_size1*3)+2) );
else g.drawString("File not exist", x, y+((v_font_size1*3)+2));
}
//MAIN

View File

@ -1 +0,0 @@
{"id":"widclkbttm.wid.js","name":"Digital clock bttom widget","type":"widget","version":"0.05","files":"widclkbttm.info,widclkbttm.wid.js"}

View File

@ -4,9 +4,7 @@ WIDGETS["wdclkbttm"]={area:"br",width:Bangle.CLOCK?0:60,draw:function() {
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
}
if (!this.width) return; // if size not right, return
if (process.env.BOARD=='BANGLEJS'||process.env.BOARD=='EMSCRIPTEN') v_font_size=16
else v_font_size=13;
g.reset().setFontVector(v_font_size).setFontAlign(-1, 0);
g.reset().setFont("6x8", 2).setFontAlign(-1, 0);
var time = require("locale").time(new Date(),1);
g.drawString(time, this.x, this.y+11, true); // 5 * 6*2 = 60
// queue draw in one minute

View File

@ -1 +0,0 @@
{"id":"widhwbttm.wid.js","name":"hw stats bttom widget","type":"widget","version":"0.02","files":"widhwbttm.info,widhwbttm.wid.js"}

View File

@ -1,47 +1,57 @@
(function() {
let intervalRef = null;
var v_switch; // show stats
if (process.env.BOARD=='BANGLEJS'||process.env.BOARD=='EMSCRIPTEN') v_font_size=15
else v_font_size=12;
var v_str_hw=new String();
if (process.env.BOARD=='BANGLEJS'||process.env.BOARD=='EMSCRIPTEN') var v_font_size=16;
else var v_font_size=14;
if (v_switch == null || v_switch == '') v_switch=0;
function draw(){
if (!Bangle.CLOCK == !this.width) { // if we're the wrong size for if we have a clock or not...
this.width = Bangle.CLOCK?0:60;
return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw
}
if (!this.width) return; // if size not right, return
function draw(){
if (Bangle.CLOCK) return;
if (v_switch==0) {
//var v_hw=process.memory();
v_str_hw=process.memory().free+"/"+process.memory().total;
v_switch++;
} else if (v_switch==1) {
if (v_switch==0) {
// var v_hw=process.env.VERSION;
v_str_hw="V:"+process.env.VERSION;
v_switch++;
} else if (v_switch==2) {
v_str_hw="M:"+process.env.BOARD;
v_str_hw="V "+process.env.VERSION.substr(0,6);
v_switch++;
} else if (v_switch==1) {
v_str_hw=process.env.BOARD.substr(0,3)+".."+process.env.BOARD.substr(process.env.BOARD.length-3,3);
v_switch++;
}
else if (v_switch==2) {
v_str_hw="Bat "+E.getBattery()+"%";
v_switch++;
} else {
stor=require("Storage").getStats();
if (v_switch==3) {
v_str_hw="St:"+stor.freeBytes;
}
else {
// text prefix has to be 4char
stor=require("Storage").getStats();
if (v_switch==3) {
v_str_hw="Fre "+process.memory().free;
//+"/"+process.memory().total;
v_switch++;
}
else if (v_switch==4) {
v_str_hw="Sto "+stor.freeBytes;
v_switch++;
} else if (v_switch==4) {
v_str_hw="TrB:"+stor.trashBytes;
} else if (v_switch==5) {
v_str_hw="Tra "+stor.trashBytes;
v_switch++;
} else if (v_switch==5) {
v_str_hw="Fil:"+stor.fileCount;
} else if (v_switch==6) {
v_str_hw="Fil "+stor.fileCount;
v_switch=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";
}
} //else storage
g.reset().setFontVector(v_font_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:Bangle.CLOCK?0:60,draw:draw};
WIDGETS["wdhwbttm"]={area:"bl",width:60,draw:draw};
//{area:"bl",width:Bangle.CLOCK?0:60,draw:draw};
if (Bangle.isLCDOn) intervalRef = setInterval(()=>WIDGETS["wdhwbttm"].draw(), 10*1000);
})()