From 62dec35e4dd47e22b951eab86328b3632f303e57 Mon Sep 17 00:00:00 2001 From: Jeph <4734254+strongbutgood@users.noreply.github.com> Date: Tue, 15 Mar 2022 23:40:58 +1300 Subject: [PATCH 1/3] Ensure calibration registers loaded before read --- bmp280.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bmp280.py b/bmp280.py index 07f8d3d..0220251 100644 --- a/bmp280.py +++ b/bmp280.py @@ -90,6 +90,8 @@ def __init__(self, i2c_bus, addr=0x76, use_case=BMP280_CASE_HANDHELD_DYN): self._bmp_i2c = i2c_bus self._i2c_addr = addr + while self.is_updating: + pass # read calibration data # < little-endian # H unsigned short From 99c5c6e43b79322b334765f1936040a5204d1d70 Mon Sep 17 00:00:00 2001 From: Jeph <4734254+strongbutgood@users.noreply.github.com> Date: Wed, 16 Mar 2022 11:15:04 +1300 Subject: [PATCH 2/3] Separate calibration data read Add confirmation that calibration data is read. Refuse to read calibration data while registers are written from NVM. --- bmp280.py | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/bmp280.py b/bmp280.py index 0220251..3c91626 100644 --- a/bmp280.py +++ b/bmp280.py @@ -90,24 +90,11 @@ def __init__(self, i2c_bus, addr=0x76, use_case=BMP280_CASE_HANDHELD_DYN): self._bmp_i2c = i2c_bus self._i2c_addr = addr - while self.is_updating: - pass - # read calibration data - # < little-endian - # H unsigned short - # h signed short - self._T1 = unp(' Date: Sun, 20 Mar 2022 23:47:57 +1300 Subject: [PATCH 3/3] Remove conditions from calibrate method --- bmp280.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bmp280.py b/bmp280.py index 3c91626..1dd158d 100644 --- a/bmp280.py +++ b/bmp280.py @@ -132,10 +132,6 @@ def _gauge(self): self._p = 0 def calibrate(self): - if self._T1 != 0: - return True - if self.is_updating: - return False # read calibration data # < little-endian # H unsigned short @@ -152,7 +148,7 @@ def calibrate(self): self._P7 = unp('