Skip to content
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

Fix for 'Active basal - NS Care Portal' status line #77

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## About this fork and me (andyrozman/urchin-cgm)

I am Android APS user and I have been using this watchface for a while now... I created very nice configuration which displays
all data I need. One of the lines I use is 'Active basal - NS Care Portal', which was actually implemented little bit wrong. It worked
great for absolute values, but not for percent ones. This change fixes exactly that. So if you use TBR as percent, and use 'Active basal'
status line, then this fix is for you.

Here is link to compiled watchface [pbw file](https://raw.githubusercontent.com/andyrozman/urchin-cgm/master/release/urchin-cgm.pbw), so that you don't need to do it by yourself (it's little bit of hassle to make build work, since
original Pebble site is no longer there, but you can use Rebble service instead).



## Watchface

A Pebble watchface to view data from a continuous glucose monitor in graph format, like this:

![Screenshot](http://i.imgur.com/xefGk6A.png)
Expand Down
Binary file modified release/urchin-cgm.pbw
Binary file not shown.
2 changes: 1 addition & 1 deletion src/js/constants.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"VERSION" : "0.0.14",
"VERSION" : "0.0.15",

"DEBUG": false,
"DEV_CONFIG_URL": "",
Expand Down
33 changes: 25 additions & 8 deletions src/js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,18 @@ var data = function(c, maxSGVCount) {
if (treatments.length && treatments[0]['duration']) {
var start = new Date(treatments[0]['created_at']);
var rate;
if (treatments[0]['percent'] && parseFloat(treatments[0]['percent']) === 0) {
var ratePercent;
var rateType;
if (treatments[0]['percent']) {
rate = 0;
ratePercent = treatments[0]['percent'];
rateType = 'percent';
} else {
rate = parseFloat(treatments[0]['absolute']);
ratePercent = null;
rateType = 'absolute';
}
return {start: start, rate: rate, duration: parseFloat(treatments[0]['duration'])};
return {start: start, rate: rate, duration: parseFloat(treatments[0]['duration']), rate_percent: ratePercent, rate_type : rateType };
} else {
return undefined;
}
Expand Down Expand Up @@ -365,14 +371,25 @@ var data = function(c, maxSGVCount) {
if (profileBasal === undefined && tempBasal === undefined) {
return {text: '-'};
} else if (tempBasal !== undefined && Date.now() - tempBasal.start < tempBasal.duration * 60 * 1000) {
var diff = tempBasal.rate - profileBasal;
return {
text: _roundBasal(tempBasal.rate) + 'U/h ' + (diff >= 0 ? '+' : '') + _roundBasal(diff),
recency: Math.round((new Date() - tempBasal.start) / 1000),
};

if (tempBasal.rate_type == 'percent') {
var percent = 100 + tempBasal.rate_percent;
var value = profileBasal * (percent / 100);
return {
text: percent + '% (' + _roundBasal(value) + ' U/h)',
recency: Math.round((new Date() - tempBasal.start) / 1000),
};
} else {
var diff = tempBasal.rate - profileBasal;
return {
text: _roundBasal(tempBasal.rate) + ' U/h ' + (diff >= 0 ? '+' : '') + _roundBasal(diff),
recency: Math.round((new Date() - tempBasal.start) / 1000),
};
}

} else {
return {
text: _roundBasal(profileBasal) + 'U/h',
text: _roundBasal(profileBasal) + ' U/h',
recency: 0
};
}
Expand Down