Skip to content

Commit

Permalink
Merge pull request #5 from nightscout/pebble-trend
Browse files Browse the repository at this point in the history
test adding arrows for @jwedding
  • Loading branch information
bewest committed Jun 2, 2014
2 parents e0228e1 + 2bfd94d commit 7be8fc2
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/pebble.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
var DIRECTIONS = {
NONE: 0
, DoupleUp: 1
, SingleUp: 2
, FortyFiveUp: 3
, Flat: 4
, FortyFiveDown: 5
, SingleDown: 6
, DoubleDown: 7
, 'NOT COMPUTABLE': 8
, 'RATE OUT OF RANGE': 9
};

function directionToTrend (direction) {
var trend = 8;
if (direction in DIRECTIONS) {
trend = DIRECTIONS[direction];
}
return trend;
}

function pebble (req, res) {
var FORTY_MINUTES = 2400000;
Expand All @@ -16,7 +36,10 @@ function pebble (req, res) {
var obj = {};
obj.sgv = element.sgv;
obj.bgdelta = (last ? (last.sgv - element.sgv) : 0);
obj.trend = 0;
if ('direction' in element) {
obj.trend = directionToTrend(element.direction);
obj.direction = element.direction;
}
// obj.y = element.sgv;
// obj.x = element.date;
obj.datetime = element.date;
Expand Down

0 comments on commit 7be8fc2

Please sign in to comment.