From 411f02dcff2b15e5b90804273e8dca030a46298e Mon Sep 17 00:00:00 2001 From: Conr86 Date: Tue, 9 Jul 2019 13:36:59 +1000 Subject: [PATCH] Reorganised repo --- sgp30/__init__.py => __init__.py | 0 sgp30/crc.py => crc.py | 2 +- setup.py | 2 +- sgp30/sgp30.py => sgp30.py | 33 ++++++++++++++++---------------- 4 files changed, 19 insertions(+), 18 deletions(-) rename sgp30/__init__.py => __init__.py (100%) rename sgp30/crc.py => crc.py (94%) rename sgp30/sgp30.py => sgp30.py (84%) diff --git a/sgp30/__init__.py b/__init__.py similarity index 100% rename from sgp30/__init__.py rename to __init__.py diff --git a/sgp30/crc.py b/crc.py similarity index 94% rename from sgp30/crc.py rename to crc.py index e69785e..f05a46b 100644 --- a/sgp30/crc.py +++ b/crc.py @@ -18,6 +18,6 @@ class CRC8: s.crc = crc & 0xFF return s.crc -#print(CRC8().hash([1,144])) +# print(CRC8().hash([1,144])) #print(hex(CRC8().hash([0xBE, 0xEF]))) #[1, 144, 76, 0, 6, 39] diff --git a/setup.py b/setup.py index f563bb3..4ff3a00 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( long_description=readme, author='Connor Kneebone', author_email='connor@sfxrescue.com', - url='https://github.com/zinob/RPI_SGP30', + url='https://github.com/Conr86/PySGP30', license='MIT', packages=find_packages(exclude=('tests')), install_requires=['smbus2'], diff --git a/sgp30/sgp30.py b/sgp30.py similarity index 84% rename from sgp30/sgp30.py rename to sgp30.py index 469dbcc..0c9acb5 100644 --- a/sgp30/sgp30.py +++ b/sgp30.py @@ -8,6 +8,7 @@ from .crc import CRC8 DEVICE_BUS = 1 + class _cmds(): """container class for mapping between human readable names and the command values used by the sgp""" SGP30Cmd = namedtuple("SGP30Cmd", ["commands", "replylen", "waittime"]) @@ -57,20 +58,20 @@ class SGP30(): return self.SGP30Packet(answer, r, crc_ok) def dump_baseline(self): - baseline = self.read_write(_cmds.GET_BASELINE) - if baseline.crc_ok == True: - print(baseline) - else: - print("Ignoring baseline due to invalid CRC") - + baseline = self.read_write(_cmds.GET_BASELINE) + if baseline.crc_ok == True: + print(baseline) + else: + print("Ignoring baseline due to invalid CRC") + def set_baseline(self): - crc, _ = self._raw_validate_crc(self._baseline) - if len(self._baseline) == 6 and crc == True: - self.read_write(_cmds.new_set_baseline(self._baseline)) - return True - else: - #print("Failed to load baseline, invalid data") - return False + crc, _ = self._raw_validate_crc(self._baseline) + if len(self._baseline) == 6 and crc == True: + self.read_write(_cmds.new_set_baseline(self._baseline)) + return True + else: + #print("Failed to load baseline, invalid data") + return False def read_measurements(self): return self.read_write(_cmds.IAQ_MEASURE) @@ -110,9 +111,9 @@ def main(): print(sgp.read_serial()) sgp.init_sgp() for i in range(300): - print(sgp.read_measurements()) - time.sleep(0.1) - sgp.store_baseline() + print(sgp.read_measurements()) + time.sleep(0.1) + sgp.store_baseline() bus.close()