-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsps30.py
35 lines (28 loc) · 857 Bytes
/
sps30.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
35
try:
from typing import Any, Optional
except ImportError:
Any = str
_SPS30_IMPORTED = False
_SPS30_IMPORTED_MP = False
SPS30_I2C = Any
# Machine-dependent import
# if not _SPS30_IMPORTED:
# try:
# from ph4_sense_py.sensors.sps30_ada import SPS30_I2C # type: ignore
#
# _SPS30_IMPORTED = True
# except ImportError:
# pass
if not _SPS30_IMPORTED:
assert SPS30_I2C is Any
try:
from ph4_sense.sensors.sps30_mp import SPS30_I2C
_SPS30_IMPORTED = True
_SPS30_IMPORTED_MP = True
except ImportError as e:
print("SPS30 import error:", e)
raise
def sps30_factory(bus, address: int = 0x69, **kwargs) -> Optional[SPS30_I2C]:
if not _SPS30_IMPORTED:
return None
return SPS30_I2C(bus, address, **kwargs) if _SPS30_IMPORTED_MP else SPS30_I2C(bus, address)