From 54865cfbb93bb2f5ce3caa74bcb99f0a3b25f59b Mon Sep 17 00:00:00 2001 From: Jan Schenk Date: Wed, 3 Apr 2019 23:05:13 +0200 Subject: [PATCH 01/14] Add relevant OR part as well The relevant "OR echo '{"batteryVoltage":3340,"battery":99}'" is still missing. So the script still crashes NightScout in its current state. Now added that line and the explaining line of comment as well. Tested for several days on Pi & RadioFruit Bonnet combo with two different NS instances. --- scripts/getvoltage.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/getvoltage.sh b/scripts/getvoltage.sh index 9c656ea..95b98fc 100755 --- a/scripts/getvoltage.sh +++ b/scripts/getvoltage.sh @@ -4,5 +4,6 @@ command -v socat >/dev/null 2>&1 || { echo >&2 "I require socat but it's not ins [[ $RESPONSE == "{}" ]] && unset RESPONSE RESPONSE=`echo '{"command":"read_voltage"}' | socat -,ignoreeof ~/src/openaps-menu/socket-server.sock | sed -n 's/.*"response":\([^}]*\)}/\1/p'` -[[ $RESPONSE = *[![:space:]]* ]] && echo $RESPONSE +[[ $RESPONSE = *[![:space:]]* ]] && echo $RESPONSE || echo '{"batteryVoltage":3340,"battery":99}' +# the OR at the end of the above line uploads a fake voltage (3340) and percentage (99), to work around a problem with nighscout crashing when receiving a null value #./getvoltage.sh | sed -n 's/.*"response":\([^}]*\)}/\1/p' From 0fe9f4ec0c32237b6a3749535ddfd2a7ef7a79b5 Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sun, 14 Apr 2019 20:32:45 -0400 Subject: [PATCH 02/14] Support for Adafruit Radiofruit RFM69HCW Bonnet --- config/buttons.json | 4 ++-- config/display.json | 4 ++-- static/unicorn_128x32.png | Bin 0 -> 443 bytes 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 static/unicorn_128x32.png diff --git a/config/buttons.json b/config/buttons.json index 6f1a4f1..c36d2a8 100644 --- a/config/buttons.json +++ b/config/buttons.json @@ -1,7 +1,7 @@ { "gpios": { - "buttonUp": 17, - "buttonDown": 27 + "buttonUp": 5, + "buttonDown": 6 }, "options": { "socketPath": "/var/run/pi-buttons.sock", diff --git a/config/display.json b/config/display.json index ec77703..17e6563 100644 --- a/config/display.json +++ b/config/display.json @@ -1,5 +1,5 @@ { "title": " ", - "height": 64, - "displayLines": 8 + "height": 32, + "displayLines": 4 } diff --git a/static/unicorn_128x32.png b/static/unicorn_128x32.png new file mode 100644 index 0000000000000000000000000000000000000000..d492fdfbb8e0ba6e68e66dbc87df12bf74c766c4 GIT binary patch literal 443 zcmeAS@N?(olHy`uVBq!ia0vp^4M42G$P6SOym^!cq!^2X+?^QKos)S9vjzBsxB}__|Nk$&IsYz@#aZAHSytZ#=;>pBU!qf z-{cP4j7)1gN3Wmyh8N3}R+u$h+{W_NGV|)HeEykxO|M8_l6vKB_2qQw-OJ}D{9?GL zy3kGX408(G*?+sf{r@#f@Sst*aF(CKW9HqT*-g%>yUQ2ud?qoiUq*hT_A|v_t+Rek eIV8ep_?h1+GPO`L{Pb^7FnPNAxvX Date: Mon, 22 Apr 2019 16:41:39 -0400 Subject: [PATCH 03/14] Update getvoltage.sh --- scripts/getvoltage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/getvoltage.sh b/scripts/getvoltage.sh index 95b98fc..f8e16ad 100755 --- a/scripts/getvoltage.sh +++ b/scripts/getvoltage.sh @@ -2,8 +2,8 @@ command -v socat >/dev/null 2>&1 || { echo >&2 "I require socat but it's not installed. Aborting."; exit 1; } -[[ $RESPONSE == "{}" ]] && unset RESPONSE RESPONSE=`echo '{"command":"read_voltage"}' | socat -,ignoreeof ~/src/openaps-menu/socket-server.sock | sed -n 's/.*"response":\([^}]*\)}/\1/p'` +[[ $RESPONSE == "{}" ]] && unset RESPONSE [[ $RESPONSE = *[![:space:]]* ]] && echo $RESPONSE || echo '{"batteryVoltage":3340,"battery":99}' # the OR at the end of the above line uploads a fake voltage (3340) and percentage (99), to work around a problem with nighscout crashing when receiving a null value #./getvoltage.sh | sed -n 's/.*"response":\([^}]*\)}/\1/p' From cc7ccd98579089e0403ff3ce402b1691659ad27f Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Fri, 21 Jun 2019 23:05:05 -0400 Subject: [PATCH 04/14] Unified Explorer HAT and Radiofruit configs, blank status screen script option (effectively puts the screen to sleep but leaves menus working) --- config/buttons-explorerhat.json | 10 +++ .../{buttons.json => buttons-radiofruit.json} | 0 config/display.json | 13 +++- index.js | 61 ++++++++++++------ static/unicorn_128x64.png | Bin 0 -> 541 bytes 5 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 config/buttons-explorerhat.json rename config/{buttons.json => buttons-radiofruit.json} (100%) create mode 100644 static/unicorn_128x64.png diff --git a/config/buttons-explorerhat.json b/config/buttons-explorerhat.json new file mode 100644 index 0000000..6590ecf --- /dev/null +++ b/config/buttons-explorerhat.json @@ -0,0 +1,10 @@ +{ + "gpios": { + "buttonup": 17, + "buttondown": 27 + }, + "options": { + "socketPath": "/var/run/pi-buttons.sock", + "reconnectTimeout": 3000 + } +} diff --git a/config/buttons.json b/config/buttons-radiofruit.json similarity index 100% rename from config/buttons.json rename to config/buttons-radiofruit.json diff --git a/config/display.json b/config/display.json index 17e6563..427d0c0 100644 --- a/config/display.json +++ b/config/display.json @@ -1,5 +1,12 @@ { - "title": " ", - "height": 32, - "displayLines": 4 + "radiofruit": { + "title": " ", + "height": 32, + "displayLines": 4 + }, + "explorerHat": { + "title": " ", + "height": 64, + "displayLines": 8 + } } diff --git a/index.js b/index.js index 7d653b3..af132b0 100644 --- a/index.js +++ b/index.js @@ -16,17 +16,42 @@ var i2cBus = i2c.openSync(1); var openapsDir = "/root/myopenaps"; //if you're using a nonstandard OpenAPS directory, set that here. NOT RECOMMENDED. -// setup the display -var displayConfig = require('./config/display.json'); +try { + var preferences = JSON.parse(fs.readFileSync(openapsDir+"/preferences.json")); +} catch (e) { + console.error("Could not load preferences.json", e); +} + +// setup the display, depending on its size (Eadiofruit is 128x32 and Explorer HAT is 128x64) +if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { + var displayConfig = require('./config/display.json').radiofruit; +} else { + var displayConfig = require('./config/display.json').explorerHat; +} + +console.log(displayConfig); displayConfig.i2cBus = i2cBus; try { var display = require('./lib/display/ssd1306')(displayConfig); - displayImage('./static/unicorn.png'); //display logo + if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { + displayImage('./static/unicorn_128x32.png'); + } else { + displayImage('./static/unicorn_128x64.png'); + } } catch (e) { console.warn("Could not setup display:", e); } +function displayImage(pathToImage) { + pngparse.parseFile(pathToImage, function(err, image) { + if(err) + throw err + display.clear(); + display.oled.drawBitmap(image.data); + }); +} + // setup battery voltage monitor var voltageConfig = require('./config/voltage.json') voltageConfig.i2cBus = i2cBus @@ -47,37 +72,31 @@ socketServer }) .on('displaystatus', function () { if (display) { - var preferences; - fs.readFile(openapsDir+'/preferences.json', function (err, data) { - if (err) throw err; - preferences = JSON.parse(data); if (preferences.status_screen && preferences.status_screen == "bigbgstatus") { bigBGStatus(display, openapsDir); } else if (preferences.status_screen && preferences.status_screen == "off") { //don't auto-update the screen if it's turned off + } else if (preferences.status_screen && preferences.status_screen == "blank") { + display.clear(true); } else { graphStatus(display, openapsDir); //default to graph status } - }); } }) -function displayImage(pathToImage) { - pngparse.parseFile(pathToImage, function(err, image) { - if(err) - throw err - display.clear(); - display.oled.drawBitmap(image.data); - }); -} - // load up graphical status scripts const graphStatus = require('./scripts/status.js'); const bigBGStatus = require('./scripts/big_bg_status.js'); // if you want to add your own status display script, it will be easiest to replace one of the above! // setup the menus -var buttonsConfig = require('./config/buttons.json'); + +if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { + var buttonsConfig = require('./config/buttons-radiofruit.json'); +} else { + var buttonsConfig = require('./config/buttons-explorerhat.json'); +} + var menuConfig = { menuFile: process.cwd() + path.sep + './config/menus/menu.json', // file path for the menu definition onChange: showMenu, // method to call when menu changes @@ -100,7 +119,11 @@ hidMenu bigBGStatus(display, openapsDir); }) .on('showlogo', function () { - displayImage('./static/unicorn.png'); + if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { + displayImage('./static/unicorn_128x32.png'); + } else { + displayImage('./static/unicorn_128x64.png'); + } }) .on('showvoltage', function () { voltage() diff --git a/static/unicorn_128x64.png b/static/unicorn_128x64.png new file mode 100644 index 0000000000000000000000000000000000000000..3981ca747c781541de590857f80a609e69a301de GIT binary patch literal 541 zcmV+&0^Cf z;Xa3Zdd6JO&{~z$;MN)v+BQOi@Ab2jB$>po{nFEcB8f|hO~0JkZ}8%yeG->|q(QvR z4m)`gp8|FREO+xvE|YbI6l;jeaq2AznmaiElLi+#NQd$pxK4xX7=%NWE*q6rI-AE* zxYRf4`O$8i&c?BnfsPn04zqb0jbq0jz^PPYJzx`ls`PH6+wH#yYZJVXMZl`&P#Gua z#8ev)<_zc;H3ppjH6yGuGQruA`3lMvwdRKlsWZS2NuS}}Q0GBLt8T!{xV#LKnboq0 z$ho5%$fhXv zZXoz^P#mob6nUZG_&E%H-Hv0Q!A}lX6ZTV`GO)G`FdLcR*ntTn$s&B;HDTegh{cTm f+!2SGLk0f;@lLx_rWOYF00000NkvXXu0mjf4LAHE literal 0 HcmV?d00001 From 225c08bcd24dad0ff57425453bbae6de7f518440 Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Fri, 21 Jun 2019 23:32:08 -0400 Subject: [PATCH 05/14] Add carbs required to warnings line --- scripts/status.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/status.js b/scripts/status.js index 4db9fe2..09a361c 100644 --- a/scripts/status.js +++ b/scripts/status.js @@ -91,7 +91,7 @@ if(batterylevel) { display.oled.fillRect(127-batt, 58, batt, 5, 1, false); //fill battery gauge } -//display reason for not looping, and move the graph to make room for the message +//display warning messages, and move the graph to make room for the message var yOffset = 0; //offset for graph, if we need to move it if (status && suggested) { var notLoopingReason = suggested.reason; @@ -116,6 +116,10 @@ if (status && suggested) { display.oled.writeString(font, 1, "BG data too old", 1, false, 0, false); yOffset = 3; } + else if (suggested.carbsReq) { + display.oled.writeString(font, 1, "Carbs Requiredd: "+suggested.carbsReq+'g', 1, false, 0, false); + yOffset = 3; + } //add more on-screen warnings/messages, maybe some special ones for xdrip-js users? } From 5638134a40b5854f26a5a4f5e9eb91dad8377f92 Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Fri, 21 Jun 2019 23:37:40 -0400 Subject: [PATCH 06/14] Update README.md New status screen option. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 675d22c..9c83a41 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # openaps-menu -This is the repository holding the menu-based software code, which you may choose to add to an Explorer HAT or other screen-based rig in order to visualize and enter information into a Pi-based #OpenAPS rig. +This is the repository holding the menu-based software code, which you may choose to add to an Explorer HAT or other screen-based rig (e.g., Adafruit Radiofruit Bonnet) in order to visualize and enter information into a Pi-based #OpenAPS rig. See [here](https://github.com/EnhancedRadioDevices/Explorer-HAT) for more details on the Explorer HAT hardware. @@ -8,8 +8,9 @@ You can set your preferred auto-updating status screen using the following setti `"status_screen": "bigbgstatus"` will display the big BG status screen (no graph). -`"status_screen": "off"` will turn the auto-updating screen off. +`"status_screen": "off"` will not auto-update the status screen. +`"status_screen": "blank"` will wipe the screen during the auto-update, but will wake up when you press a button to let you access menu options. By default, the auto-updating status script will invert the display about 50% of the time, to prevent burn-in on the OLED screen. You can turn this off with the following setting in your `~/myopenaps/preferences.json`: From 30ea016d33334d9fd98b56fcca752ecf0b5f65bf Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sat, 22 Jun 2019 00:02:59 -0400 Subject: [PATCH 07/14] Text-only radiofruit status screen --- index.js | 7 +- scripts/status-radiofruit.js | 180 +++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 scripts/status-radiofruit.js diff --git a/index.js b/index.js index af132b0..9d9e726 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,6 @@ if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { var displayConfig = require('./config/display.json').explorerHat; } -console.log(displayConfig); displayConfig.i2cBus = i2cBus; try { @@ -78,6 +77,8 @@ socketServer //don't auto-update the screen if it's turned off } else if (preferences.status_screen && preferences.status_screen == "blank") { display.clear(true); + } else if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { + radiofruitStatus(display, openapsDir); //radiofruit text status script } else { graphStatus(display, openapsDir); //default to graph status } @@ -87,6 +88,7 @@ socketServer // load up graphical status scripts const graphStatus = require('./scripts/status.js'); const bigBGStatus = require('./scripts/big_bg_status.js'); +const radiofruitStatus = require('./scripts/status-radiofruit.js'); // if you want to add your own status display script, it will be easiest to replace one of the above! // setup the menus @@ -118,6 +120,9 @@ hidMenu .on('showbigBGstatus', function () { bigBGStatus(display, openapsDir); }) +.on('showRadiofruitStatus', function () { + radiofruitStatus(display, openapsDir); +}) .on('showlogo', function () { if (preferences.hardwaretype && preferences.hardwaretype == "radiofruit") { displayImage('./static/unicorn_128x32.png'); diff --git a/scripts/status-radiofruit.js b/scripts/status-radiofruit.js new file mode 100644 index 0000000..a45a13c --- /dev/null +++ b/scripts/status-radiofruit.js @@ -0,0 +1,180 @@ +var fs = require('fs'); +var font = require('oled-font-5x7'); + +// Rounds value to 'digits' decimal places +function round(value, digits) +{ + if (! digits) { digits = 0; } + var scale = Math.pow(10, digits); + return Math.round(value * scale) / scale; +} + +function convert_bg(value, profile) +{ + if (profile != null && profile.out_units == "mmol/L") + { + return round(value / 18, 1).toFixed(1); + } + else + { + return Math.round(value); + } +} + +function stripLeadingZero(value) +{ + var re = /^(-)?0+(?=[\.\d])/; + return value.toString().replace( re, '$1'); +} + +module.exports = radiofruitStatus; + +// +//Start of status display function +// + +function radiofruitStatus(display, openapsDir) { + +display.oled.clearDisplay(true); //clear display buffer + +//Parse all the .json files we need +try { + var profile = JSON.parse(fs.readFileSync(openapsDir+"/settings/profile.json")); +} catch (e) { + console.error("Status screen display error: could not parse profile.json: ", e); +} +try { + var status = JSON.parse(fs.readFileSync(openapsDir+"/monitor/status.json")); +} catch (e) { + console.error("Status screen display error: could not parse status.json: ", e); +} +try { + var suggested = JSON.parse(fs.readFileSync(openapsDir+"/enact/suggested.json")); +} catch (e) { + console.error("Status screen display error: could not parse suggested.json: ", e); +} +try { + var bg = JSON.parse(fs.readFileSync(openapsDir+"/monitor/glucose.json")); +} catch (e) { + console.error("Status screen display error: could not parse glucose.json: ", e); +} +try { + var temp = JSON.parse(fs.readFileSync(openapsDir+"/monitor/last_temp_basal.json")); + var statusStats = fs.statSync(openapsDir+"/monitor/last_temp_basal.json"); +} catch (e) { + console.error("Status screen display error: could not parse last_temp_basal.json: ", e); +} +try { + var iob = JSON.parse(fs.readFileSync(openapsDir+"/monitor/iob.json")); +} catch (e) { + console.error("Status screen display error: could not parse iob.json: ", e); +} +try { + var cob = JSON.parse(fs.readFileSync(openapsDir+"/monitor/meal.json")); +} catch (e) { + console.error("Status screen display error: could not parse meal.json: ", e); +} + +//display warning messages +if (status && suggested) { + var notLoopingReason = suggested.reason; + display.oled.setCursor(0,16); + if (status.suspended == true) { + display.oled.writeString(font, 1, "PUMP SUSPENDED", 1, false, 0, false); + yOffset = 3; + } + else if (status.bolusing == true) { + display.oled.writeString(font, 1, "PUMP BOLUSING", 1, false, 0, false); + yOffset = 3; + } + else if (notLoopingReason.includes("CGM is calibrating")) { + display.oled.writeString(font, 1, "CGM calib./???/noisy", 1, false, 0, false); + yOffset = 3; + } + else if (notLoopingReason.includes("CGM data is unchanged")) { + display.oled.writeString(font, 1, "CGM data unchanged", 1, false, 0, false); + yOffset = 3; + } + else if (notLoopingReason.includes("BG data is too old")) { + display.oled.writeString(font, 1, "BG data too old", 1, false, 0, false); + yOffset = 3; + } + else if (suggested.carbsReq) { + display.oled.writeString(font, 1, "Carbs Requiredd: "+suggested.carbsReq+'g', 1, false, 0, false); + yOffset = 3; + } +//add more on-screen warnings/messages, maybe some special ones for xdrip-js users? +} + +//calculate timeago for BG +var startDate = new Date(bg[0].date); +var endDate = new Date(); +var minutes = Math.round(( (endDate.getTime() - startDate.getTime()) / 1000) / 60); +if (bg[0].delta) { + var delta = Math.round(bg[0].delta); +} else if (bg[1] && bg[0].date - bg[1].date > 200000 ) { + var delta = Math.round(bg[0].glucose - bg[1].glucose); +} else if (bg[2] && bg[0].date - bg[2].date > 200000 ) { + var delta = Math.round(bg[0].glucose - bg[2].glucose); +} else if (bg[3] && bg[0].date - bg[3].date > 200000 ) { + var delta = Math.round(bg[0].glucose - bg[3].glucose); +} else { + var delta = 0; +} +//display BG number and timeago, add plus sign if delta is positive +display.oled.setCursor(0,24); +if (delta >= 0) { + display.oled.writeString(font, 1, "BG:"+convert_bg(bg[0].glucose, profile)+"+"+stripLeadingZero(convert_bg(delta, profile))+" "+minutes+"m", 1, false, 0, false); +} else { + display.oled.writeString(font, 1, "BG:"+convert_bg(bg[0].glucose, profile)+""+stripLeadingZero(convert_bg(delta, profile))+" "+minutes+"m", 1, false, 0, false); +} + +//display current temp basal and how long ago it was set, on the first line of the screen +if (statusStats && temp) { + startDate = new Date(statusStats.mtime); + endDate = new Date(); + var minutesAgo = Math.round(( (endDate.getTime() - startDate.getTime()) / 1000) / 60); + //display current temp basal + display.oled.setCursor(0,0); + var tempRate = Math.round(temp.rate*10)/10; + display.oled.writeString(font, 1, "TB: "+temp.duration+'m '+tempRate+'U/h '+'('+minutesAgo+'m ago)', 1, false, 0, false); +} + +//display current COB and IOB, on the second line of the screen +if (iob && cob) { + display.oled.setCursor(0,8); + display.oled.writeString(font, 1, "COB: "+cob.mealCOB+"g IOB: "+iob[0].iob+'U', 1, false, 0, false); +} + +//render clock +var clockDate = new Date(); +var clockHour = clockDate.getHours(); +clockHour = (clockHour < 10 ? "0" : "") + clockHour; +var clockMin = clockDate.getMinutes(); +clockMin = (clockMin < 10 ? "0" : "") + clockMin; +display.oled.setCursor(97, 24); +display.oled.writeString(font, 1, clockHour+":"+clockMin, 1, false, 0, false); + +display.oled.dimDisplay(true); //dim the display +display.oled.update(); //write buffer to the screen + +fs.readFile(openapsDir+"/preferences.json", function (err, data) { + if (err) throw err; + preferences = JSON.parse(data); + if (preferences.wearOLEDevenly && preferences.wearOLEDevenly.includes("off")) { + display.oled.invertDisplay(false); + } + else if (preferences.wearOLEDevenly && preferences.wearOLEDevenly.includes("nightandday") && (clockHour >= 20 || clockHour <= 8)) { + display.oled.invertDisplay(false); + } + else if (preferences.wearOLEDevenly && preferences.wearOLEDevenly.includes("nightandday") && (clockHour <= 20 && clockHour >= 8)) { + display.oled.invertDisplay(true); + } + else { + display.oled.invertDisplay((endDate % 2 == 1)); + } +}); + + // +}//End of status display function + // From e62ca9ea0db880e00b8d8462c66c95cb056e9a6c Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sat, 22 Jun 2019 00:12:21 -0400 Subject: [PATCH 08/14] Undefined check Crash prevention... --- scripts/status.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/status.js b/scripts/status.js index 09a361c..09c0126 100644 --- a/scripts/status.js +++ b/scripts/status.js @@ -133,8 +133,7 @@ if (profile) { if (bg) { //render BG graph - var numBGs = (suggested.predBGs != undefined) ? (72) : (120); //fill the whole graph with BGs if there are no predictions - var date = new Date(); + var numBGs = ((suggested != undefined) && (suggested.predBGs != undefined)) ? (72) : (120); //fill the whole graph with BGs if there are no predictions var date = new Date(); var zerotime = date.getTime() - ((numBGs * 5) * 600); var zero_x = numBGs + 5; for (var i = 0; i < numBGs; i++) { From 20e55aaeeee86fe6f999f287d1d5bd9d927bea6e Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sat, 22 Jun 2019 00:14:02 -0400 Subject: [PATCH 09/14] Oops --- scripts/status.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/status.js b/scripts/status.js index 09c0126..614fc06 100644 --- a/scripts/status.js +++ b/scripts/status.js @@ -134,6 +134,7 @@ if (profile) { if (bg) { //render BG graph var numBGs = ((suggested != undefined) && (suggested.predBGs != undefined)) ? (72) : (120); //fill the whole graph with BGs if there are no predictions var date = new Date(); + var date = new Date(); var zerotime = date.getTime() - ((numBGs * 5) * 600); var zero_x = numBGs + 5; for (var i = 0; i < numBGs; i++) { From b92e7226e44bcfc6295bc5ea0e7bef6bdf1f1e4e Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sat, 22 Jun 2019 00:34:35 -0400 Subject: [PATCH 10/14] Capitalization --- config/buttons-explorerhat.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/buttons-explorerhat.json b/config/buttons-explorerhat.json index 6590ecf..6f1a4f1 100644 --- a/config/buttons-explorerhat.json +++ b/config/buttons-explorerhat.json @@ -1,7 +1,7 @@ { "gpios": { - "buttonup": 17, - "buttondown": 27 + "buttonUp": 17, + "buttonDown": 27 }, "options": { "socketPath": "/var/run/pi-buttons.sock", From a17a05415e9e0871ccb7952c85a80283182ede7a Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sat, 22 Jun 2019 00:37:58 -0400 Subject: [PATCH 11/14] Temp basal mismatch loop failure message. --- scripts/status-radiofruit.js | 4 ++++ scripts/status.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/scripts/status-radiofruit.js b/scripts/status-radiofruit.js index a45a13c..ec151de 100644 --- a/scripts/status-radiofruit.js +++ b/scripts/status-radiofruit.js @@ -99,6 +99,10 @@ if (status && suggested) { display.oled.writeString(font, 1, "BG data too old", 1, false, 0, false); yOffset = 3; } + else if (notLoopingReason.includes("currenttemp rate")) { + display.oled.writeString(font, 1, "Temp. mismatch", 1, false, 0, false); + yOffset = 3; + } else if (suggested.carbsReq) { display.oled.writeString(font, 1, "Carbs Requiredd: "+suggested.carbsReq+'g', 1, false, 0, false); yOffset = 3; diff --git a/scripts/status.js b/scripts/status.js index 614fc06..baef023 100644 --- a/scripts/status.js +++ b/scripts/status.js @@ -116,6 +116,10 @@ if (status && suggested) { display.oled.writeString(font, 1, "BG data too old", 1, false, 0, false); yOffset = 3; } + else if (notLoopingReason.includes("currenttemp rate")) { + display.oled.writeString(font, 1, "Temp. mismatch", 1, false, 0, false); + yOffset = 3; + } else if (suggested.carbsReq) { display.oled.writeString(font, 1, "Carbs Requiredd: "+suggested.carbsReq+'g', 1, false, 0, false); yOffset = 3; From bb945a88bca741c6df1e55c379a8b5b49bf53335 Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Sat, 22 Jun 2019 00:43:08 -0400 Subject: [PATCH 12/14] Low pump battery warning. --- scripts/status-radiofruit.js | 13 +++++++++++-- scripts/status.js | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/status-radiofruit.js b/scripts/status-radiofruit.js index ec151de..73188ec 100644 --- a/scripts/status-radiofruit.js +++ b/scripts/status-radiofruit.js @@ -74,12 +74,21 @@ try { } catch (e) { console.error("Status screen display error: could not parse meal.json: ", e); } +try { + var pumpbattery = JSON.parse(fs.readFileSync(openapsDir+"/monitor/battery.json")); +} catch (e) { + console.error("Status screen display error: could not parse battery.json: ", e); +} //display warning messages -if (status && suggested) { +if (status && suggested && pumpbattery) { var notLoopingReason = suggested.reason; display.oled.setCursor(0,16); - if (status.suspended == true) { + if (pumpbattery.voltage <= 1.25) { + display.oled.writeString(font, 1, "LOW PUMP BATT.", 1, false, 0, false); + yOffset = 3; + } + else if (status.suspended == true) { display.oled.writeString(font, 1, "PUMP SUSPENDED", 1, false, 0, false); yOffset = 3; } diff --git a/scripts/status.js b/scripts/status.js index baef023..d9f1b1e 100644 --- a/scripts/status.js +++ b/scripts/status.js @@ -79,6 +79,11 @@ try { } catch (e) { console.error("Status screen display error: could not parse meal.json: ", e); } +try { + var pumpbattery = JSON.parse(fs.readFileSync(openapsDir+"/monitor/battery.json")); +} catch (e) { + console.error("Status screen display error: could not parse battery.json: ", e); +} //Process and display battery gauge if(batterylevel) { @@ -93,10 +98,14 @@ if(batterylevel) { //display warning messages, and move the graph to make room for the message var yOffset = 0; //offset for graph, if we need to move it -if (status && suggested) { +if (status && suggested && pumpbattery) { var notLoopingReason = suggested.reason; display.oled.setCursor(0,16); - if (status.suspended == true) { + if (pumpbattery.voltage <= 1.25) { + display.oled.writeString(font, 1, "LOW PUMP BATT.", 1, false, 0, false); + yOffset = 3; + } + else if (status.suspended == true) { display.oled.writeString(font, 1, "PUMP SUSPENDED", 1, false, 0, false); yOffset = 3; } From 7eb611cdfd61a26c6669dc94325f586abca9e729 Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Mon, 24 Jun 2019 15:37:59 -0400 Subject: [PATCH 13/14] Update dependencies to latest. --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3fb697e..13759ff 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,13 @@ "author": "", "license": "MIT", "dependencies": { - "extend": "^3.0.1", - "i2c-bus": "^1.2.2", - "menube": "^1.0.3", - "oled-font-5x7": "^1.0.0", - "oled-i2c-bus": "git+https://github.com/bnielsen1965/oled-i2c-bus.git", + "extend": "^3.0.2", + "i2c-bus": "^4.0.10", + "menube": "^1.0.4", + "oled-font-5x7": "^1.0.3", + "oled-i2c-bus": "^1.0.11", "pngparse": "^2.0.1", - "node-pi-buttons": "git+https://github.com/bnielsen1965/node-pi-buttons.git", - "rpi-gpio": "^0.9.1" + "node-pi-buttons": "^1.0.1", + "rpi-gpio": "^2.1.3" } } From 007eecf193d11640638333c9beee0df4f5c6b49b Mon Sep 17 00:00:00 2001 From: Jon Cluck Date: Mon, 24 Jun 2019 15:43:54 -0400 Subject: [PATCH 14/14] Typo --- scripts/status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/status.js b/scripts/status.js index d9f1b1e..b280e05 100644 --- a/scripts/status.js +++ b/scripts/status.js @@ -130,7 +130,7 @@ if (status && suggested && pumpbattery) { yOffset = 3; } else if (suggested.carbsReq) { - display.oled.writeString(font, 1, "Carbs Requiredd: "+suggested.carbsReq+'g', 1, false, 0, false); + display.oled.writeString(font, 1, "Carbs Required: "+suggested.carbsReq+'g', 1, false, 0, false); yOffset = 3; } //add more on-screen warnings/messages, maybe some special ones for xdrip-js users?