diff --git a/apps/tempmonitor/ChangeLog b/apps/tempmonitor/ChangeLog new file mode 100644 index 000000000..2d9536fb9 --- /dev/null +++ b/apps/tempmonitor/ChangeLog @@ -0,0 +1 @@ +0.01: 1st version: saves values to csv diff --git a/apps/tempmonitor/README.md b/apps/tempmonitor/README.md new file mode 100644 index 000000000..094a47868 --- /dev/null +++ b/apps/tempmonitor/README.md @@ -0,0 +1,40 @@ +# Temperature Monitor (with logging) +Temperature monitor that shows temperature on real time but also allows to store in a file for a later process. + +Compatible with BangleJS1,BangleJS2,and EMSCRIPTENx emulators + +## Pictures: + +Bangle JS1 + +![](photo_banglejs1.jpg) + +Screenshot BJS2 + +![](ss_emul_bjs2.png) + +Screenshot BJS1 + +![](ss_emul_bjs1.png) + + + +## Usage + +Open and see a temperature in the screen +Download the CSV file and process in your favourite spreadsheet software + +## Features + +Colours, all inputs , graph, widgets loaded +Counter for Times Display + + +## Controls + +exit: left side + + +## Creator + +Daniel Perez \ No newline at end of file diff --git a/apps/tempmonitor/app.png b/apps/tempmonitor/app.png new file mode 100644 index 000000000..f1e576134 Binary files /dev/null and b/apps/tempmonitor/app.png differ diff --git a/apps/tempmonitor/metadata.json b/apps/tempmonitor/metadata.json new file mode 100644 index 000000000..50842150c --- /dev/null +++ b/apps/tempmonitor/metadata.json @@ -0,0 +1,15 @@ +{ + "id": "tempmonitor", + "name": "Temperature monitor", + "version": "0.01", + "description": "Displays the current temperature and stores in a CSV file", + "icon": "app.png", + "tags": "tool", + "supports": ["BANGLEJS", "BANGLEJS2"], + "screenshots": [{"url":"photo_banglejs1.jpg"}], + "allow_emulator": true, + "storage": [ + {"name":"tempmonitor.app.js","url":"tempmonitor.app.js"}, + {"name":"tempmonitor.img","url":"tempmonitor.img","evaluate":true} + ] +} diff --git a/apps/tempmonitor/photo_banglejs1.jpg b/apps/tempmonitor/photo_banglejs1.jpg new file mode 100644 index 000000000..58c64b01c Binary files /dev/null and b/apps/tempmonitor/photo_banglejs1.jpg differ diff --git a/apps/tempmonitor/ss_emul_bjs1.png b/apps/tempmonitor/ss_emul_bjs1.png new file mode 100644 index 000000000..da7a53bd1 Binary files /dev/null and b/apps/tempmonitor/ss_emul_bjs1.png differ diff --git a/apps/tempmonitor/ss_emul_bjs2.png b/apps/tempmonitor/ss_emul_bjs2.png new file mode 100644 index 000000000..4d4f8ec6c Binary files /dev/null and b/apps/tempmonitor/ss_emul_bjs2.png differ diff --git a/apps/tempmonitor/tempmonitor.app.js b/apps/tempmonitor/tempmonitor.app.js new file mode 100644 index 000000000..514378151 --- /dev/null +++ b/apps/tempmonitor/tempmonitor.app.js @@ -0,0 +1,136 @@ +// Temperature monitor that saves a log of measures +// Version 001 standalone for developer +// PEND +//test with small savefreq +var v_mode_debug=0; //, 0=no, 1 min, 2 prone detail +//var required for drawing with dynamic screen +var rect = Bangle.appRect; +var history = []; +var readFreq=5000; //ms //PEND add to settings +var saveFreq=30000; //ms +var v_saveToFile='Y'; //Y save //N +//with upload file º is not displayed properly +//with upload RAM º is displayed +var v_t_symbol="";//ºC +var v_saved_entries=0; +var filename ="temphistory.csv"; +var lastMeasure = new String(); +var v_model=process.env.BOARD; + +//EMSCRIPTEN,EMSCRIPTEN2 +if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') { + v_font_size1=16; + v_font_size2=60; + //g.setColor("#0ff"); //light color + }else{ + v_font_size1=10; + v_font_size2=40; + //g.setColor("#000"); //black or dark + } + +function onTemperature(v_temp) { + if (v_mode_debug>1) console.log("v_temp in "+v_temp); + ClearBox(); + //g.setFont("6x8",2).setFontAlign(0,0); + 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); + //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 + g.drawString(v_temp+v_t_symbol, x, y); + g.flip(); +} +// from: BJS2 pressure sensor, BJS1 inbuilt thermistor +function drawTemperature() { + if(v_model.substr(0,10)!='EMSCRIPTEN'){ + if (Bangle.getPressure) { + Bangle.getPressure().then(p =>{if (p) onTemperature(p);}); + } else onTemperature(E.getTemperature()); + } + else onTemperature(11);//fake temp for emulators +} + +function saveToFile() { + //input global vars: lastMeasure + var a=new Date(); + var strlastSaveTime=new String(); + var 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); + + if (v_saveToFile=='Y'){ + require("Storage").open(filename,"a").write(strlastSaveTime+","+lastMeasure+"\n"); + //(getTime()+","); + v_saved_entries=v_saved_entries+1; + } +} + +function drawGraph(){ + var img_obj_thermo = { + width : 36, height : 36, bpp : 3, + transparent : 0, + buffer : require("heatshrink").decompress(atob("AEFt2AMKm3bsAMJjdt23ABhEB+/7tgaJ///DRUP//7tuADRP923YDRXbDRfymwaJhu/koaK7eyiwaK3cLDRlWDRY1NKBY1Ztu5kjmJg3cyVI7YMHgdu5Mkyu2fxHkyVJjdgDRFJkmRDRPsDQNbDQ5QBGoONKBJrBoxQIQwO2eRcbtu24AMIFIQLJAH4AMA==")) + }; + g.drawImage(img_obj_thermo,rect.x2-50,rect.y2/2); + g.flip(); +} +function ClearScreen(){ + //avoid widget areas + g.reset(1).clearRect(rect.x, rect.y+24, rect.x2, rect.y2-24); + g.flip(); +} +function ClearBox(){ + //custom boxarea , left space for static graph at right + g.reset(1).clearRect(rect.x, rect.y+24, rect.x2-50, rect.y2-24); + g.flip(); +} +function introPage(){ + //g.setFont("6x8",2).setFontAlign(0,0); + g.setFontVector(v_font_size1).setFontAlign(-1,0); + //x alignment. -1=left (default), 0=center, 1=right + var x=3; + //dynamic positions as height for BJS1 is double than BJS2 + var y = (rect.y+rect.y2)/2 + 10; + 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) ); + 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) ) + else g.drawString("File not exist", x, y+((v_font_size1*3)+2)); +} +//MAIN +Bangle.loadWidgets(); +Bangle.setUI({ + mode : "custom", + back : function() {load();} +}); + +ClearScreen(); +introPage(); + +setInterval(function() { + drawTemperature(); +}, readFreq); //ms + +if (v_saveToFile=="Y") { + setInterval(function() { + saveToFile(); + }, saveFreq); //ms +} +setTimeout(ClearScreen, 3500); +setTimeout(drawGraph,4000); +setTimeout(drawTemperature,4500); \ No newline at end of file diff --git a/apps/tempmonitor/tempmonitor.img b/apps/tempmonitor/tempmonitor.img new file mode 100644 index 000000000..275109759 Binary files /dev/null and b/apps/tempmonitor/tempmonitor.img differ diff --git a/apps/tempmonitor/tempmonitor.info b/apps/tempmonitor/tempmonitor.info new file mode 100644 index 000000000..1824c5c86 --- /dev/null +++ b/apps/tempmonitor/tempmonitor.info @@ -0,0 +1 @@ +{"id":"tempmonitor","name":"tempmonitor","src":"tempmonitor.app.js","icon":"tempmonitor.img","version":"0.01","files":"tempmonitor.info,tempmonitor.app.js,tempmonitor.img"} \ No newline at end of file diff --git a/apps/testuserinput/README.md b/apps/testuserinput/README.md index 47c1779be..7e1160bfb 100644 --- a/apps/testuserinput/README.md +++ b/apps/testuserinput/README.md @@ -43,7 +43,7 @@ Colours, font, user input, image, load widgets - Press center area - Prints Touch3 - Swipe Left - Displays Switch OFF image - Swipe Right - Displays Switch ON image - - BTN1 - Prints Button1 + - BTN1 - Prints Button1, Down (moves selection to next row) - BTN2 - Prints Button2 - BTN3 - Quit to Launcher diff --git a/apps/widclkbttm/ChangeLog b/apps/widclkbttm/ChangeLog index 9dc8f8d2c..a7141a7dd 100644 --- a/apps/widclkbttm/ChangeLog +++ b/apps/widclkbttm/ChangeLog @@ -2,3 +2,5 @@ 0.02: Modification for bottom widget area and text color 0.03: based in widclk v0.05 compatible at same time, bottom area and color 0.04: refactored to use less memory, and allow turning on/off when quick-switching apps +0.05: Different font size for bangle.js2 and bangle.js1 + diff --git a/apps/widclkbttm/metadata.json b/apps/widclkbttm/metadata.json index 7c5fe4b63..2bcd6bc58 100644 --- a/apps/widclkbttm/metadata.json +++ b/apps/widclkbttm/metadata.json @@ -2,7 +2,7 @@ "id": "widclkbttm", "name": "Digital clock (Bottom) widget", "shortName": "Digital clock Bottom Widget", - "version": "0.04", + "version": "0.05", "description": "Displays time in the bottom of the screen (may not be compatible with some apps)", "icon": "widclkbttm.png", "type": "widget", diff --git a/apps/widclkbttm/widclkbttm.info b/apps/widclkbttm/widclkbttm.info new file mode 100644 index 000000000..ac349a3dc --- /dev/null +++ b/apps/widclkbttm/widclkbttm.info @@ -0,0 +1 @@ +{"id":"widclkbttm.wid.js","name":"Digital clock bttom widget","type":"widget","version":"0.05","files":"widclkbttm.info,widclkbttm.wid.js"} \ No newline at end of file diff --git a/apps/widclkbttm/widclkbttm.wid.js b/apps/widclkbttm/widclkbttm.wid.js index c5e85318c..74957826b 100644 --- a/apps/widclkbttm/widclkbttm.wid.js +++ b/apps/widclkbttm/widclkbttm.wid.js @@ -1,10 +1,12 @@ WIDGETS["wdclkbttm"]={area:"br",width:Bangle.CLOCK?0:60,draw:function() { 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; + this.width = Bangle.CLOCK?0:60; return setTimeout(Bangle.drawWidgets,1); // widget changed size - redraw } if (!this.width) return; // if size not right, return - g.reset().setFont("6x8", 2).setFontAlign(-1, 0).setColor("#0ff"); // cyan + 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); 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 diff --git a/apps/widhwbttm/ChangeLog b/apps/widhwbttm/ChangeLog index 1d7b3be61..23192b302 100644 --- a/apps/widhwbttm/ChangeLog +++ b/apps/widhwbttm/ChangeLog @@ -1,2 +1,2 @@ 0.01: 1st ver, inspired in some code from widclkbttm (Digital clock bttom widget) - +0.02: Correction, intervals, dynamic color and font size depending on device diff --git a/apps/widhwbttm/metadata.json b/apps/widhwbttm/metadata.json index 053be5a36..f455e90a7 100644 --- a/apps/widhwbttm/metadata.json +++ b/apps/widhwbttm/metadata.json @@ -2,7 +2,7 @@ "id": "widhwbttm", "name": "HW stats (Bottom) widget", "shortName": "Digital clock Bottom Widget", - "version": "0.01", + "version": "0.02", "description": "Displays technical info and mem stats in the bottom of the screen (may not be compatible with some apps)", "icon": "widhwbttm.png", "type": "widget", diff --git a/apps/widhwbttm/widhwbttm.info b/apps/widhwbttm/widhwbttm.info index c92adad11..e73dfcc89 100644 --- a/apps/widhwbttm/widhwbttm.info +++ b/apps/widhwbttm/widhwbttm.info @@ -1 +1 @@ -{"id":"widhwbttm.wid.js","name":"hw stats bttom widget","type":"widget","version":"0.01","files":"widhwbttm.info,widhwbttm.wid.js"} \ No newline at end of file +{"id":"widhwbttm.wid.js","name":"hw stats bttom widget","type":"widget","version":"0.02","files":"widhwbttm.info,widhwbttm.wid.js"} \ No newline at end of file diff --git a/apps/widhwbttm/widhwbttm.wid.js b/apps/widhwbttm/widhwbttm.wid.js index d251cf2f0..688ceaa7e 100644 --- a/apps/widhwbttm/widhwbttm.wid.js +++ b/apps/widhwbttm/widhwbttm.wid.js @@ -1,7 +1,8 @@ (function() { + let intervalRef = null; var v_switch; // show stats - if (process.env.BOARD=='BANGLEJS'||process.env.BOARD=='EMSCRIPTEN') v_font_size=16 - else v_font_size=13; + 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 (v_switch == null || v_switch == '') v_switch=0; function draw(){ @@ -35,11 +36,12 @@ v_switch=0; } } - g.reset().setFontVector(v_font_size).setFontAlign(-1, 0).setColor("#0ff"); - //clean a longer previous string - g.drawString(" ", this.x, this.y+11, true); + 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}; +if (Bangle.isLCDOn) intervalRef = setInterval(()=>WIDGETS["wdhwbttm"].draw(), 10*1000); })()