diff options
author | Ben West <bewest@gmail.com> | 2016-06-14 21:27:57 -0700 |
---|---|---|
committer | Ben West <bewest@gmail.com> | 2016-06-14 21:27:57 -0700 |
commit | 3ba9510e452b77dae1f071e4035909f03f359b57 (patch) | |
tree | 27d0eb786a55bb6b507737eb3774c6a016cad3e0 | |
parent | 606e95c34bd2bcb569db71484c4270d0a59aa57c (diff) |
add noise field to EGVRecords
CC @jasoncalabrese, re https://github.com/openaps/dexcom_reader/issues/12
-rw-r--r-- | dexcom_reader/constants.py | 1 | ||||
-rw-r--r-- | dexcom_reader/database_records.py | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/dexcom_reader/constants.py b/dexcom_reader/constants.py index 421c190..628d325 100644 --- a/dexcom_reader/constants.py +++ b/dexcom_reader/constants.py | |||
@@ -63,6 +63,7 @@ MAX_POSSIBLE_COMMAND = 255 | |||
63 | EGV_VALUE_MASK = 1023 | 63 | EGV_VALUE_MASK = 1023 |
64 | EGV_DISPLAY_ONLY_MASK = 32768 | 64 | EGV_DISPLAY_ONLY_MASK = 32768 |
65 | EGV_TREND_ARROW_MASK = 15 | 65 | EGV_TREND_ARROW_MASK = 15 |
66 | EGV_NOISE_MASK = 112 | ||
66 | 67 | ||
67 | BATTERY_STATES = [None, 'CHARGING', 'NOT_CHARGING', 'NTC_FAULT', 'BAD_BATTERY'] | 68 | BATTERY_STATES = [None, 'CHARGING', 'NOT_CHARGING', 'NTC_FAULT', 'BAD_BATTERY'] |
68 | 69 | ||
diff --git a/dexcom_reader/database_records.py b/dexcom_reader/database_records.py index 9274d24..22ba279 100644 --- a/dexcom_reader/database_records.py +++ b/dexcom_reader/database_records.py | |||
@@ -289,7 +289,7 @@ class SensorRecord(GenericTimestampedRecord): | |||
289 | class EGVRecord(GenericTimestampedRecord): | 289 | class EGVRecord(GenericTimestampedRecord): |
290 | # uint, uint, ushort, byte, ushort | 290 | # uint, uint, ushort, byte, ushort |
291 | # (system_seconds, display_seconds, glucose, trend_arrow, crc) | 291 | # (system_seconds, display_seconds, glucose, trend_arrow, crc) |
292 | FIELDS = ['glucose', 'trend_arrow'] | 292 | FIELDS = ['glucose', 'trend_arrow', 'noise'] |
293 | FORMAT = '<2IHcH' | 293 | FORMAT = '<2IHcH' |
294 | 294 | ||
295 | @property | 295 | @property |
@@ -322,6 +322,9 @@ class EGVRecord(GenericTimestampedRecord): | |||
322 | arrow_value = ord(self.full_trend) & constants.EGV_TREND_ARROW_MASK | 322 | arrow_value = ord(self.full_trend) & constants.EGV_TREND_ARROW_MASK |
323 | return constants.TREND_ARROW_VALUES[arrow_value] | 323 | return constants.TREND_ARROW_VALUES[arrow_value] |
324 | 324 | ||
325 | @property | ||
326 | def noise (self): | ||
327 | return (ord(self.data[3]) & constants.EGV_NOISE_MASK) >> 4 | ||
325 | def __repr__(self): | 328 | def __repr__(self): |
326 | if self.is_special: | 329 | if self.is_special: |
327 | return '%s: %s' % (self.display_time, self.glucose_special_meaning) | 330 | return '%s: %s' % (self.display_time, self.glucose_special_meaning) |