Skip to content

Commit

Permalink
add noise field to EGVRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
bewest committed Jun 15, 2016
1 parent 606e95c commit 3ba9510
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions dexcom_reader/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class CrcError(Error):
EGV_VALUE_MASK = 1023
EGV_DISPLAY_ONLY_MASK = 32768
EGV_TREND_ARROW_MASK = 15
EGV_NOISE_MASK = 112

BATTERY_STATES = [None, 'CHARGING', 'NOT_CHARGING', 'NTC_FAULT', 'BAD_BATTERY']

Expand Down
5 changes: 4 additions & 1 deletion dexcom_reader/database_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def rssi(self):
class EGVRecord(GenericTimestampedRecord):
# uint, uint, ushort, byte, ushort
# (system_seconds, display_seconds, glucose, trend_arrow, crc)
FIELDS = ['glucose', 'trend_arrow']
FIELDS = ['glucose', 'trend_arrow', 'noise']
FORMAT = '<2IHcH'

@property
Expand Down Expand Up @@ -322,6 +322,9 @@ def trend_arrow(self):
arrow_value = ord(self.full_trend) & constants.EGV_TREND_ARROW_MASK
return constants.TREND_ARROW_VALUES[arrow_value]

@property
def noise (self):
return (ord(self.data[3]) & constants.EGV_NOISE_MASK) >> 4
def __repr__(self):
if self.is_special:
return '%s: %s' % (self.display_time, self.glucose_special_meaning)
Expand Down

0 comments on commit 3ba9510

Please sign in to comment.