From 0223507e1e29417e37444f209bc9ac672fdbf537 Mon Sep 17 00:00:00 2001 From: hh Date: Tue, 1 Jan 2019 11:10:11 +0100 Subject: [PATCH] bme280_xxx.py: Make the code a little bit more PEP8 compliant --- bme280_float.py | 27 +++++++++++++++++---------- bme280_int.py | 33 ++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/bme280_float.py b/bme280_float.py index 5731b79..f96b7d0 100644 --- a/bme280_float.py +++ b/bme280_float.py @@ -1,3 +1,10 @@ +# Updated 2018 +# This module is based on the below cited resources, which are all +# based on the documentation as provided in the Bosch Data Sheet and +# the sample implementation provided therein. +# +# Final Document: BST-BME280-DS002-15 +# # Authors: Paul Cunnane 2016, Peter Dahlebrg 2016 # # This module borrows from the Adafruit BME280 Python library. Original @@ -31,6 +38,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +# import time from ustruct import unpack, unpack_from @@ -82,7 +90,7 @@ class BME280: _, self.dig_H1 = unpack("> 15) * (((((((h * self.dig_H6) >> 10) * - (((h * self.dig_H3) >> 11) + 32768)) >> 10) + - 2097152) * self.dig_H2 + 8192) >> 14)) + (self.dig_H5 * h)) + 16384) >> 15) * + (((((((h * self.dig_H6) >> 10) * + (((h * self.dig_H3) >> 11) + 32768)) >> 10) + 2097152) * + self.dig_H2 + 8192) >> 14)) h = h - (((((h >> 15) * (h >> 15)) >> 7) * self.dig_H1) >> 4) h = 0 if h < 0 else h h = 419430400 if h > 419430400 else h @@ -193,7 +205,7 @@ class BME280: @sealevel.setter def sealevel(self, value): - if 300 < value < 1200: # just ensure some reasonable value + if 300 < value < 1200: # just ensure some reasonable value self.__sealevel = value @property @@ -203,8 +215,8 @@ class BME280: ''' from math import pow try: - p = 44330 * (1.0 - pow((self.read_compensated_data()[1] / 256) - / self.__sealevel, 0.1903)) + p = 44330 * (1.0 - pow((self.read_compensated_data()[1] / 256) / + self.__sealevel, 0.1903)) except: p = 0.0 return p @@ -233,4 +245,3 @@ class BME280: h = h / 1024 return ("{}C".format(t / 100), "{:.02f}hPa".format(p/100), "{:.02f}%".format(h)) -