From d5ba6a9cab47b9030b7de01e89cb610019f34bbe Mon Sep 17 00:00:00 2001 From: Simon Albinsson Date: Mon, 16 Apr 2018 12:46:23 +0000 Subject: [PATCH] New main fuction should actually be usefull. --- sgp30/sgp30.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/sgp30/sgp30.py b/sgp30/sgp30.py index c4b7ca3..f18d025 100644 --- a/sgp30/sgp30.py +++ b/sgp30/sgp30.py @@ -117,29 +117,13 @@ class Sgp30(): def main(): with SMBusWrapper(1) as bus: - rw=partial(read_write) - i2c_geral_call(bus) - print("Features: %s"%repr(rw(GET_FEATURES))) - print("Serial: %s"%repr(rw(GET_SERIAL))) - init_sgp(bus) - #print(rw(_cmds.IAQ_SELFTEST)) - print("Testing meassure") - print(rw(_cmds.IAQ_MEASURE)) - print("Testing meassure again") - sleep(1) - print("Running") - n=0 - while(True): - start = time() - n+=1 - co2eq, tvoc = rw(_cmds.IAQ_MEASURE).data - res = ( "%s CO_2eq: %d ppm, TVOC: %d"%( asctime(), co2eq, tvoc )) - print(res) - f.write("%i %i %i \n"%(time(),co2eq,tvoc)) - store_baseline(n) - elapsed = (time() - start) - sleep(1 - elapsed ) - + sgp=Sgp30(bus,baseline_filename=BASELINE_FILENAME+".TESTING") + print("resetting all i2c devices") + sgp.i2c_geral_call() + print(sgp.read_features()) + print(sgp.read_serial()) + sgp.init_sgp() + print(sgp.read_measurements()) bus.close() if __name__ == "__main__":