-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsgp30.py
34 lines (27 loc) · 827 Bytes
/
sgp30.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
31
32
33
34
try:
from typing import Any, Optional
except ImportError:
Any = str
_SGP30_IMPORTED = False
_SGP30_IMPORTED_MP = False
SGP30 = Any
# Machine-dependent import
# if not _SGP30_IMPORTED:
# try:
# from ph4_sense_py.sensors.sgp30_ada import AdaSGP30 as SGP30 # type: ignore
#
# _SGP30_IMPORTED = True
# except ImportError:
# pass
if not _SGP30_IMPORTED:
assert SGP30 is Any
try:
from ph4_sense.sensors.sgp30_mp import SGP30
_SGP30_IMPORTED = True
_SGP30_IMPORTED_MP = True
except ImportError as e:
print("SGP32 import error:", e)
def sgp30_factory(bus, address: int = 0x58, **kwargs) -> Optional[SGP30]:
if not _SGP30_IMPORTED:
return None
return SGP30(bus, address, **kwargs) if _SGP30_IMPORTED_MP else SGP30(bus, address)