-
Notifications
You must be signed in to change notification settings - Fork 18
Bugfixes and improvements for openaps-menu. #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
c0c1817
Converted to use node-pi-buttons module and made pi-buttons a separat…
bnielsen1965 e7bb7c6
Fix for low number of BGs and offset
cluckj c86941e
customizations for jon's production rig
cluckj cb9139c
Merge pull request #8 from openaps/master
cluckj e8e8b56
Merge pull request #9 from cluckj/patch-2
cluckj 6195056
various personalizations and possible improvements
cluckj d351559
revert screenoff code and add pump status to screen
cluckj 966dbe7
status screen improvements and bugfixes
cluckj 4de7a5e
Update README.md
cluckj a789f53
improvements, bugfixes, and exit on display malfunction
cluckj e2df2b4
Merge branch 'jon-dev' of https://github.com/cluckj/openaps-menu into…
cluckj 6ee63b1
Clearer error messages
cluckj 75bc4ac
comments
cluckj 67fcc1f
fixing error handling when only writing to the screen once
cluckj 3dd7e39
bugfixes
cluckj 7c935cb
stop calling status scripts from the commandline
cluckj 315dd9f
use socket server to control display
cluckj 9794f54
Merge pull request #10 from bnielsen1965/node-pi-buttons
cluckj 30e5d3b
improvements and bugfixes
cluckj 68e13c8
status screen for cas
cluckj 2a35a2b
nice typo
cluckj 07ea8a9
Remove custom rig code
cluckj 2ca742a
revert readme
cluckj a1fac9a
fixes and improvements
cluckj 80875e6
Merge pull request #11 from cluckj/jon-dev
cluckj 12b38ac
Revert "upgrade jon-dev with node pi buttons"
cluckj 905b0de
Merge pull request #12 from cluckj/revert-10-node-pi-buttons
cluckj 837282d
Don't crash if buttons are pressed & screen broken
cluckj 1595979
bugfixes and add preferences toggle for status
cluckj 769a592
Merge pull request #13 from cluckj/jon-dev
cluckj 0fee879
more preferences, update big_bg_status.js
cluckj 162e5a5
Merge pull request #14 from cluckj/jon-dev
cluckj 281334e
Update README.md
cluckj 521eeec
Update menu.json
cluckj 06c0d51
Delete casstatus.js
cluckj ca7e7a0
Merge branch 'master' into master
cluckj 7cfbc0a
Revert package.json
cluckj b3fecda
Remove comma
cluckj 89372a2
Add preferences switch info
cluckj f0addab
Add 8am-8pm invert display option.
cluckj 7efd198
Add 8am-8pm invert display option.
cluckj 2995f52
Variable name bugfix
cluckj b3bf41a
Logic fix for day/night inversion
cluckj 8059d33
Logic fix for day/night inversion
cluckj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| 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 = bigbgstatus; | ||
|
|
||
| // | ||
| //Start of status display function | ||
| // | ||
|
|
||
| function bigbgstatus(display, openapsDir) { | ||
|
|
||
| display.oled.clearDisplay(true); //clear the buffer | ||
|
|
||
| //Parse all the .json files we need | ||
| try { | ||
| var profile = JSON.parse(fs.readFileSync(openapsDir+"/settings/profile.json")); | ||
| } catch (e) { | ||
| // Note: profile.json is optional as it's only needed for mmol conversion for now. Print an error, but not return | ||
| console.error("Status screen display error: could not parse profile.json: ", e); | ||
| } | ||
| try { | ||
| var batterylevel = JSON.parse(fs.readFileSync(openapsDir+"/monitor/edison-battery.json")); | ||
| } catch (e) { | ||
| console.error("Status screen display error: could not parse edison-battery.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 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); | ||
| } | ||
| try { | ||
| var stats = fs.statSync("/tmp/pump_loop_success"); | ||
| } catch (e) { | ||
| console.error("Status screen display error: could not find pump_loop_success"); | ||
| } | ||
|
|
||
| if(batterylevel) { | ||
| //Process and display battery gauge | ||
| display.oled.drawLine(116, 57, 127, 57, 1, false); //top | ||
| display.oled.drawLine(116, 63, 127, 63, 1, false); //bottom | ||
| display.oled.drawLine(116, 57, 116, 63, 1, false); //left | ||
| display.oled.drawLine(127, 57, 127, 63, 1, false); //right | ||
| display.oled.drawLine(115, 59, 115, 61, 1, false); //iconify | ||
| var batt = Math.round(batterylevel.battery / 10); | ||
| display.oled.fillRect(127-batt, 58, batt, 5, 1, false); //fill battery gauge | ||
| } | ||
|
|
||
| //calculate timeago for BG | ||
| if(bg && profile) { | ||
| 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, add plus sign if delta is positive | ||
| display.oled.setCursor(0,0); | ||
| if (delta >= 0) { | ||
| display.oled.writeString(font, 3, ""+convert_bg(bg[0].glucose, profile), 1, false, 0, false); | ||
| display.oled.writeString(font, 1, "+"+stripLeadingZero(convert_bg(delta, profile)), 1, false, 0, false); | ||
| display.oled.writeString(font, 2, " "+minutes+"m", 1, false, 0, false); | ||
| } else { | ||
| display.oled.writeString(font, 3, ""+convert_bg(bg[0].glucose, profile), 1, false, 0, false); | ||
| display.oled.writeString(font, 1, ""+stripLeadingZero(convert_bg(delta, profile)), 1, false, 0, false); | ||
| display.oled.writeString(font, 2, " "+minutes+"m", 1, false, 0, false); | ||
| } | ||
| } | ||
|
|
||
| //calculate timeago for last successful loop | ||
| if(stats) { | ||
| var date = new Date(stats.mtime); | ||
| var hour = date.getHours(); | ||
| hour = (hour < 10 ? "0" : "") + hour; | ||
| var min = date.getMinutes(); | ||
| min = (min < 10 ? "0" : "") + min; | ||
|
|
||
| //display last loop time | ||
| display.oled.setCursor(0,57); | ||
| display.oled.writeString(font, 1, "Last loop at: "+hour+":"+min, 1, false, 0, false); | ||
| } | ||
|
|
||
| //parse and render COB/IOB | ||
| if(iob && cob) { | ||
| display.oled.setCursor(0,23); | ||
| display.oled.writeString(font, 1, "IOB:", 1, false, 0, false); | ||
| display.oled.writeString(font, 2, " "+iob[0].iob+'U', 1, false, 0, false); | ||
| display.oled.setCursor(0,39); | ||
| display.oled.writeString(font, 1, "COB:", 1, false, 0, false); | ||
| display.oled.writeString(font, 2, " "+cob.mealCOB+'g', 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 == false) { | ||
| display.oled.invertDisplay(false); | ||
| } else { | ||
| display.oled.invertDisplay((endDate % 2 == 1)); | ||
| } | ||
| }); | ||
|
|
||
| // | ||
| }//End of status display function | ||
| // | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #!/bin/bash | ||
|
|
||
| IP=$(ip -f inet -o addr show wlan0|cut -d\ -f 7 | cut -d/ -f 1) | ||
| echo -e "Current IP Address:\n$IP\n" | ||
| echo -e "To connect: ssh\npi@$IP\n" | ||
| wlan0IP=$(ip -f inet -o addr show wlan0|cut -d\ -f 7 | cut -d/ -f 1) | ||
| bnep0IP=$(ip -f inet -o addr show bnep0|cut -d\ -f 7 | cut -d/ -f 1) | ||
| echo -e "Current WiFi IP:\n$wlan0IP\n" | ||
| echo -e "Current BT IP:\n$bnep0IP\n" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was working for me, but I think I added something below that at some point and forgot to remove the comma. Thanks.