New main fuction should actually be usefull.
This commit is contained in:
@@ -117,29 +117,13 @@ class Sgp30():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
with SMBusWrapper(1) as bus:
|
with SMBusWrapper(1) as bus:
|
||||||
rw=partial(read_write)
|
sgp=Sgp30(bus,baseline_filename=BASELINE_FILENAME+".TESTING")
|
||||||
i2c_geral_call(bus)
|
print("resetting all i2c devices")
|
||||||
print("Features: %s"%repr(rw(GET_FEATURES)))
|
sgp.i2c_geral_call()
|
||||||
print("Serial: %s"%repr(rw(GET_SERIAL)))
|
print(sgp.read_features())
|
||||||
init_sgp(bus)
|
print(sgp.read_serial())
|
||||||
#print(rw(_cmds.IAQ_SELFTEST))
|
sgp.init_sgp()
|
||||||
print("Testing meassure")
|
print(sgp.read_measurements())
|
||||||
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 )
|
|
||||||
|
|
||||||
bus.close()
|
bus.close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user