Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 Mar 4, 2018
e7bb7c6
Fix for low number of BGs and offset
cluckj Jun 16, 2018
c86941e
customizations for jon's production rig
cluckj Jun 19, 2018
cb9139c
Merge pull request #8 from openaps/master
cluckj Jun 19, 2018
e8e8b56
Merge pull request #9 from cluckj/patch-2
cluckj Jun 19, 2018
6195056
various personalizations and possible improvements
cluckj Jul 14, 2018
d351559
revert screenoff code and add pump status to screen
cluckj Jul 15, 2018
966dbe7
status screen improvements and bugfixes
cluckj Jul 15, 2018
4de7a5e
Update README.md
cluckj Jul 15, 2018
a789f53
improvements, bugfixes, and exit on display malfunction
cluckj Jul 15, 2018
e2df2b4
Merge branch 'jon-dev' of https://github.com/cluckj/openaps-menu into…
cluckj Jul 15, 2018
6ee63b1
Clearer error messages
cluckj Jul 15, 2018
75bc4ac
comments
cluckj Jul 15, 2018
67fcc1f
fixing error handling when only writing to the screen once
cluckj Jul 15, 2018
3dd7e39
bugfixes
cluckj Jul 15, 2018
7c935cb
stop calling status scripts from the commandline
cluckj Jul 16, 2018
315dd9f
use socket server to control display
cluckj Jul 16, 2018
9794f54
Merge pull request #10 from bnielsen1965/node-pi-buttons
cluckj Jul 16, 2018
30e5d3b
improvements and bugfixes
cluckj Jul 16, 2018
68e13c8
status screen for cas
cluckj Jul 16, 2018
2a35a2b
nice typo
cluckj Jul 19, 2018
07ea8a9
Remove custom rig code
cluckj Jul 19, 2018
2ca742a
revert readme
cluckj Jul 19, 2018
a1fac9a
fixes and improvements
cluckj Jul 23, 2018
80875e6
Merge pull request #11 from cluckj/jon-dev
cluckj Jul 23, 2018
12b38ac
Revert "upgrade jon-dev with node pi buttons"
cluckj Jul 23, 2018
905b0de
Merge pull request #12 from cluckj/revert-10-node-pi-buttons
cluckj Jul 23, 2018
837282d
Don't crash if buttons are pressed & screen broken
cluckj Jul 24, 2018
1595979
bugfixes and add preferences toggle for status
cluckj Aug 6, 2018
769a592
Merge pull request #13 from cluckj/jon-dev
cluckj Aug 6, 2018
0fee879
more preferences, update big_bg_status.js
cluckj Aug 6, 2018
162e5a5
Merge pull request #14 from cluckj/jon-dev
cluckj Aug 6, 2018
281334e
Update README.md
cluckj Aug 6, 2018
521eeec
Update menu.json
cluckj Aug 6, 2018
06c0d51
Delete casstatus.js
cluckj Sep 25, 2018
ca7e7a0
Merge branch 'master' into master
cluckj Sep 25, 2018
7cfbc0a
Revert package.json
cluckj Sep 25, 2018
b3fecda
Remove comma
cluckj Sep 25, 2018
89372a2
Add preferences switch info
cluckj Sep 25, 2018
f0addab
Add 8am-8pm invert display option.
cluckj Sep 25, 2018
7efd198
Add 8am-8pm invert display option.
cluckj Sep 25, 2018
2995f52
Variable name bugfix
cluckj Nov 8, 2018
b3bf41a
Logic fix for day/night inversion
cluckj Nov 8, 2018
8059d33
Logic fix for day/night inversion
cluckj Nov 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more preferences, update big_bg_status.js
  • Loading branch information
cluckj committed Aug 6, 2018
commit 0fee87992d3b9822c15d4876034a8a8cb5f5a8ef
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var fs = require('fs');

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');
displayConfig.i2cBus = i2cBus;
Expand Down Expand Up @@ -46,15 +48,15 @@ socketServer
.on('displaystatus', function () {
if (display) {
var preferences;
fs.readFile('/root/myopenaps/preferences.json', function (err, data) {
fs.readFile(openapsDir+'/preferences.json', function (err, data) {
if (err) throw err;
preferences = JSON.parse(data);
if (preferences.status_screen == "bigbgstatus") {
bigBGStatus(display);
bigBGStatus(display, openapsDir);
} else if (preferences.status_screen == "off") {
//don't auto-update the screen if it's turned off
} else {
graphStatus(display); //default to graph status
graphStatus(display, openapsDir); //default to graph status
}
});
}
Expand Down Expand Up @@ -92,10 +94,10 @@ hidMenu
.on('nothing', function () {
})
.on('showgraphstatus', function () {
graphStatus(display);
graphStatus(display, openapsDir);
})
.on('showbigBGstatus', function () {
bigBGStatus(display);
bigBGStatus(display, openapsDir);
})
.on('showlogo', function () {
displayImage('./static/unicorn.png');
Expand Down
51 changes: 31 additions & 20 deletions scripts/big_bg_status.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
module.exports = bigbgstatus;

function bigbgstatus(display) {

const path = require('path');
const extend = require('extend');
var os = require('os');
var fs = require('fs');
var font = require('oled-font-5x7');

Expand Down Expand Up @@ -34,38 +27,45 @@ function stripLeadingZero(value)
return value.toString().replace( re, '$1');
}

display.oled.dimDisplay(true); //dim the display
display.oled.clearDisplay(false); //clear the buffer
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("/root/myopenaps/settings/profile.json"));
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("/root/myopenaps/monitor/edison-battery.json"));
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("/root/myopenaps/enact/suggested.json"));
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("/root/myopenaps/monitor/glucose.json"));
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("/root/myopenaps/monitor/iob.json"));
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("/root/myopenaps/monitor/meal.json"));
var cob = JSON.parse(fs.readFileSync(openapsDir+"/monitor/meal.json"));
} catch (e) {
console.error("Status screen display error: could not parse meal.json: ", e);
}
Expand Down Expand Up @@ -139,10 +139,21 @@ if(iob && cob) {
display.oled.writeString(font, 2, " "+cob.mealCOB+'g', 1, false, 0, false);
}

//display everything in the buffer
display.oled.update();
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
//

//fandomly invert display to evenly wear the OLED diodes
display.oled.invertDisplay((endDate % 2 == 1));

} //from start of function
16 changes: 9 additions & 7 deletions scripts/status.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
var fs = require('fs');
var font = require('oled-font-5x7');
const homeDir = require('os').homedir();

var openapsDir = "/root/myopenaps"; //if you're using a nonstandard OpenAPS directory, set that here
var evenOLEDwear = true; //if you want to prevent OLED burn-in symptoms by inverting the screen, set this to true

// Rounds value to 'digits' decimal places
function round(value, digits)
Expand Down Expand Up @@ -37,7 +33,7 @@ module.exports = graphicalStatus;
//Start of status display function
//

function graphicalStatus(display) {
function graphicalStatus(display, openapsDir) {

display.oled.clearDisplay(true); //clear display buffer

Expand Down Expand Up @@ -233,9 +229,15 @@ 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

if (evenOLEDwear == true) {
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
Expand Down