|
@ -1,3 +1,4 @@
|
|||
0.01: 1st version: saves values to csv
|
||||
0.02: added HTML interface
|
||||
0.03: Added Stop/start recording, change BG color, filesize info
|
||||
0.04: Support for negative degree, Min/Max, random for emulator, clean of code
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Temperature Monitor (with logging)
|
||||
Temperature monitor that shows temperature on real time but also allows to store in a file for a later process.
|
||||
Temperature / Thermometer monitor that not only shows degrees on real time but also allows to store this info in a file for a later process.
|
||||
|
||||
Compatible with BangleJS1,BangleJS2,and EMSCRIPTENx emulators
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"id": "tempmonitor",
|
||||
"name": "Temperature monitor",
|
||||
"version": "0.03",
|
||||
"description": "Displays the current temperature and stores in a CSV file",
|
||||
"version": "0.04",
|
||||
"description": "Another thermometer, besides displaying current temperature, stores it in a CSV file",
|
||||
"icon": "app.png",
|
||||
"tags": "tool",
|
||||
"interface": "interface.html",
|
||||
|
|
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.7 KiB |
|
@ -23,6 +23,8 @@ var v_model=process.env.BOARD;
|
|||
var v_color_erase=g.getBgColor(); //original BG color overwritten on SetVariables
|
||||
var v_color=g.getColor();//original FG color
|
||||
var id_rec_intv; //var for the recording interval
|
||||
var v_t_max=-50; //preset with an opposite and impossible record measure
|
||||
var v_t_min=70;
|
||||
|
||||
if (readFreq>saveFreq) console.log("Read refresh freq should be higher than saving");
|
||||
if (v_mode_debug>0) console.log("original BG/FG color="+v_color_erase+" / "+v_color);
|
||||
|
@ -47,6 +49,17 @@ if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') {
|
|||
//print result
|
||||
function printTemperature(v_temp) {
|
||||
if (v_mode_debug>1) console.log("v_temp in "+v_temp+" entries "+v_saved_entries);
|
||||
|
||||
// Avg of temperature readings
|
||||
while (history.length>4) history.shift();
|
||||
history.push(v_temp);
|
||||
var avrTemp = E.sum(history) / history.length;
|
||||
//var t = require('locale').temp(avrTemp);
|
||||
//.replace("'","°");
|
||||
lastMeasure=avrTemp.toString();
|
||||
if (lastMeasure.length>4) lastMeasure=lastMeasure.substr(0,4);
|
||||
|
||||
|
||||
ClearBox();
|
||||
//g.setFont("6x8",2).setFontAlign(0,0);
|
||||
g.setFontVector(v_font_size1).setFontAlign(0,0);
|
||||
|
@ -64,19 +77,30 @@ function printTemperature(v_temp) {
|
|||
//else g.drawString("Rec paused : "+v_saved_entries, x, rect.y+35);
|
||||
//space for printing info
|
||||
g.drawString("Temperature:", x, rect.y+45+(v_font_size1*2));
|
||||
|
||||
if (v_temp>v_t_max) {
|
||||
g.setColor(v_color_erase);
|
||||
g.drawString(v_t_max.toString().substr(0,5), rect.x2-40,(rect.y2/2)-30);
|
||||
v_t_max=v_temp;
|
||||
g.setColor(v_color);
|
||||
}
|
||||
g.drawString(v_t_max.toString().substr(0,5), rect.x2-40,(rect.y2/2)-30);
|
||||
if (v_temp<v_t_min) {
|
||||
g.setColor(v_color_erase);
|
||||
g.drawString(v_t_min.toString().substr(0,5), rect.x2-40,(rect.y2/2)+50);
|
||||
v_t_min=v_temp;
|
||||
g.setColor(v_color);
|
||||
}
|
||||
g.drawString(v_t_min.toString().substr(0,5), rect.x2-40,(rect.y2/2)+50);
|
||||
|
||||
|
||||
|
||||
//dynamic font (g.getWidth() > 200 ? 60 : 40)
|
||||
g.setFontVector(v_font_size2).setFontAlign(0,0);
|
||||
// Avg of temperature readings
|
||||
while (history.length>4) history.shift();
|
||||
history.push(v_temp);
|
||||
var avrTemp = E.sum(history) / history.length;
|
||||
//var t = require('locale').temp(avrTemp);
|
||||
//.replace("'","°");
|
||||
lastMeasure=avrTemp.toString();
|
||||
if (lastMeasure.length>4) lastMeasure=lastMeasure.substr(0,4);
|
||||
|
||||
//DRAW temperature in the center
|
||||
//remove g.drawString(" ", x-20, y);
|
||||
g.drawString(v_temp+v_t_symbol, x, y);
|
||||
//5 char required for negative degrees
|
||||
g.drawString((v_temp.toString().substr(0,5))+v_t_symbol, x, y);
|
||||
g.flip();
|
||||
}
|
||||
// from: BJS2 pressure sensor, BJS1 inbuilt thermistor
|
||||
|
@ -86,7 +110,7 @@ function getTemperature() {
|
|||
Bangle.getPressure().then(p =>{if (p) printTemperature(p);});
|
||||
} else printTemperature(E.getTemperature());
|
||||
}
|
||||
else printTemperature(11.25);//fake temperature medition for emulators
|
||||
else printTemperature(-11.2+Math.random());//fake temperature medition for emulators
|
||||
}
|
||||
|
||||
/* Note that it changes BG and also FG to an opposite*/
|
||||
|
@ -101,9 +125,9 @@ function changeBGcolor(){
|
|||
g.setColor(v_color);
|
||||
//move to event?
|
||||
ClearScreen();
|
||||
ClearBox();
|
||||
drawGraph();
|
||||
ClearBox();//?
|
||||
getTemperature();
|
||||
drawGraph();
|
||||
//setDrawLayout(); //uncomment if layout can work with setUI
|
||||
//g.clear();//impact on widgets
|
||||
}
|
||||
|
@ -140,6 +164,7 @@ function saveToFile(){
|
|||
}
|
||||
|
||||
function drawGraph(){
|
||||
if (v_mode_debug>1) console.log("drawGraph");
|
||||
var img_obj_thermo = {
|
||||
width : 36, height : 36, bpp : 3,
|
||||
transparent : 0,
|
||||
|
@ -170,9 +195,9 @@ function introPage(){
|
|||
g.drawString(" Default values ", x, y - ((v_font_size1*3)+2));
|
||||
g.drawString("--------------------", x, y - ((v_font_size1*2)+2));
|
||||
g.drawString("Mode debug: "+v_mode_debug, x, y - ((v_font_size1*1)+2));
|
||||
g.drawString("Read freq(ms): "+readFreq, x, y );
|
||||
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) );
|
||||
g.drawString("Read frq(ms): "+readFreq, x, y );
|
||||
g.drawString("Save file: "+v_saveToFile, x, y+ ((v_font_size1*1)+2) );
|
||||
g.drawString("Save frq(ms):"+saveFreq, x, y+((v_font_size1*2)+2) );
|
||||
fr=require("Storage").read(v_filename+"\1");//suffix required
|
||||
if (fr) g.drawString("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));
|
||||
|
@ -295,10 +320,8 @@ function getFileInfo(v_filename) {
|
|||
//MAIN
|
||||
SetVariables();
|
||||
Bangle.loadWidgets();
|
||||
|
||||
ClearScreen();
|
||||
introPage();
|
||||
|
||||
//setDrawLayout(); //uncomment if layout can work with setUI
|
||||
|
||||
UserInput(); //inc SetUI and back icon
|
||||
|
@ -306,7 +329,8 @@ UserInput(); //inc SetUI and back icon
|
|||
setInterval(function() {
|
||||
getTemperature();
|
||||
}, readFreq); //ms
|
||||
|
||||
//??need
|
||||
drawGraph();
|
||||
setRecordingFreq();
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
{"id":"tempmonitor","name":"tempmonitor","src":"tempmonitor.app.js","icon":"tempmonitor.img","version":"0.03","files":"tempmonitor.info,tempmonitor.app.js,tempmonitor.img"}
|
||||
{"id":"tempmonitor","name":"tempmonitor","src":"tempmonitor.app.js","icon":"tempmonitor.img","version":"0.04","files":"tempmonitor.info,tempmonitor.app.js,tempmonitor.img"}
|