-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
example.py
30 lines (22 loc) · 866 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Example for gas detection module."""
import time
from gas_detection import GasDetection
def main():
"""Handle example."""
print('Calibrating ...')
detection = GasDetection()
try:
while True:
ppm = detection.percentage()
print('CO: {} ppm'.format(ppm[detection.CO_GAS]))
print('H2: {} ppm'.format(ppm[detection.H2_GAS]))
print('CH4: {} ppm'.format(ppm[detection.CH4_GAS]))
print('LPG: {} ppm'.format(ppm[detection.LPG_GAS]))
print('PROPANE: {} ppm'.format(ppm[detection.PROPANE_GAS]))
print('ALCOHOL: {} ppm'.format(ppm[detection.ALCOHOL_GAS]))
print('SMOKE: {} ppm\n'.format(ppm[detection.SMOKE_GAS]))
time.sleep(0.25)
except KeyboardInterrupt:
print('\nAborted by user!')
if __name__ == '__main__':
main()