summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2019-05-19 20:47:28 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2019-05-19 21:49:32 +0200
commit2f697eb803f523380f95cd18d8f1fef85afa73ef (patch)
tree4decb468e8a5596974fe02ad91760e7200a68e5a
parentfreestyle support: restore correct order of parameters. (diff)
downloadglucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.tar
glucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.tar.gz
glucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.tar.bz2
glucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.tar.lz
glucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.tar.xz
glucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.tar.zst
glucometerutils-2f697eb803f523380f95cd18d8f1fef85afa73ef.zip
-rw-r--r--glucometerutils/drivers/fslibre.py14
-rw-r--r--glucometerutils/drivers/fsprecisionneo.py8
-rw-r--r--glucometerutils/support/freestyle.py10
3 files changed, 18 insertions, 14 deletions
diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py
index 5031a04..85bfdab 100644
--- a/glucometerutils/drivers/fslibre.py
+++ b/glucometerutils/drivers/fslibre.py
@@ -101,18 +101,6 @@ def _extract_timestamp(parsed_record, prefix=''):
parsed_record[prefix + 'second'])
-def _convert_ketone_unit(raw_value):
- """Convert raw ketone value as read in the device to its value in mmol/L.
-
- As per
- https://flameeyes.github.io/glucometer-protocols/abbott/freestyle-libre.html
- this is actually not using any mg/dL→mmol/L conversion, but rather the same
- as the meter uses for blood glucose.
-
- """
- return raw_value // 18
-
-
def _parse_arresult(record):
"""Takes an array of string fields as input and parses it into a Reading."""
@@ -160,7 +148,7 @@ def _parse_arresult(record):
measure_method = common.MeasurementMethod.BLOOD_SAMPLE
cls = common.KetoneReading
# automatically convert the raw value in mmol/L
- value = _convert_ketone_unit(parsed_record['value'])
+ value = freestyle.convert_ketone_unit(parsed_record['value'])
else:
# unknown reading
return None
diff --git a/glucometerutils/drivers/fsprecisionneo.py b/glucometerutils/drivers/fsprecisionneo.py
index b818f8f..15be65c 100644
--- a/glucometerutils/drivers/fsprecisionneo.py
+++ b/glucometerutils/drivers/fsprecisionneo.py
@@ -89,4 +89,10 @@ class Device(freestyle.FreeStyleHidDevice):
raw_reading.year + 2000, raw_reading.month, raw_reading.day,
raw_reading.hour, raw_reading.minute)
- yield cls(timestamp, raw_reading.value)
+ if record and record[0] == _TYPE_KETONE_READING:
+ value = freestyle.convert_ketone_unit(raw_reading.value)
+ else:
+ value = raw_reading.value
+
+ yield cls(timestamp, value)
+
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index 816af81..d18a81f 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -64,6 +64,16 @@ def _verify_checksum(message, expected_checksum_hex):
if expected_checksum != calculated_checksum:
raise exceptions.InvalidChecksum(expected_checksum, calculated_checksum)
+def convert_ketone_unit(raw_value):
+ """Convert raw ketone value as read in the device to its value in mmol/L.
+
+ As per
+ https://flameeyes.github.io/glucometer-protocols/abbott/freestyle-libre.html
+ this is actually not using any mg/dL→mmol/L conversion, but rather the same
+ as the meter uses for blood glucose.
+
+ """
+ return raw_value / 18.0
class FreeStyleHidDevice(hiddevice.HidDevice):
"""Base class implementing the FreeStyle HID common protocol.