diff --git a/lib/pebble.js b/lib/pebble.js index dc07f68effa..37118e383ee 100644 --- a/lib/pebble.js +++ b/lib/pebble.js @@ -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; @@ -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;