Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data = ltr559.get_lux()
else:
data = 1
display_text(variables[mode], data, unit)
if mode == 4:
# variable = "oxidised"
unit = "kO"
data = gas.read_all()
data = data.oxidising / 1000
display_text(variables[mode], data, unit)
if mode == 5:
# variable = "reduced"
unit = "kO"
data = gas.read_all()
data = data.reducing / 1000
display_text(variables[mode], data, unit)
if mode == 6:
# variable = "nh3"
unit = "kO"
data = gas.read_all()
data = data.nh3 / 1000
display_text(variables[mode], data, unit)
# Exit cleanly
except KeyboardInterrupt:
sys.exit(0)
data = ltr559.get_lux()
else:
data = 1
display_text(variables[mode], data, unit)
if mode == 4:
# variable = "oxidised"
unit = "kO"
data = gas.read_all()
data = data.oxidising / 1000
display_text(variables[mode], data, unit)
if mode == 5:
# variable = "reduced"
unit = "kO"
data = gas.read_all()
data = data.reducing / 1000
display_text(variables[mode], data, unit)
if mode == 6:
# variable = "nh3"
unit = "kO"
data = gas.read_all()
data = data.nh3 / 1000
display_text(variables[mode], data, unit)
if mode == 7:
# variable = "pm1"
unit = "ug/m3"
try:
data = pms5003.read()
except pmsReadTimeoutError:
raw_temp = bme280.get_temperature()
raw_data = raw_temp - ((avg_cpu_temp - raw_temp) / factor)
save_data(0, raw_data)
display_everything()
raw_data = bme280.get_pressure()
save_data(1, raw_data)
display_everything()
raw_data = bme280.get_humidity()
save_data(2, raw_data)
if proximity < 10:
raw_data = ltr559.get_lux()
else:
raw_data = 1
save_data(3, raw_data)
display_everything()
gas_data = gas.read_all()
save_data(4, gas_data.oxidising / 1000)
save_data(5, gas_data.reducing / 1000)
save_data(6, gas_data.nh3 / 1000)
display_everything()
pms_data = None
try:
pms_data = pms5003.read()
except (SerialTimeoutError, pmsReadTimeoutError):
logging.warning("Failed to read PMS5003")
else:
save_data(7, float(pms_data.pm_ug_per_m3(1.0)))
save_data(8, float(pms_data.pm_ug_per_m3(2.5)))
save_data(9, float(pms_data.pm_ug_per_m3(10)))
display_everything()
# Exit cleanly
unit = "kO"
data = gas.read_all()
data = data.oxidising / 1000
display_text(variables[mode], data, unit)
if mode == 5:
# variable = "reduced"
unit = "kO"
data = gas.read_all()
data = data.reducing / 1000
display_text(variables[mode], data, unit)
if mode == 6:
# variable = "nh3"
unit = "kO"
data = gas.read_all()
data = data.nh3 / 1000
display_text(variables[mode], data, unit)
if mode == 7:
# variable = "pm1"
unit = "ug/m3"
try:
data = pms5003.read()
except pmsReadTimeoutError:
logging.warning("Failed to read PMS5003")
else:
data = float(data.pm_ug_per_m3(1.0))
display_text(variables[mode], data, unit)
if mode == 8:
# variable = "pm25"