-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscd4x.py
33 lines (26 loc) · 792 Bytes
/
scd4x.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
try:
from typing import Any, Optional
except ImportError:
Any = str
_SCD40X_IMPORTED = False
SCD4X = Any
SCD4X_DEFAULT_ADDR = 0x62
# Machine-dependent import
# if not _SCD40X_IMPORTED:
# try:
# from adafruit_scd4x import SCD4X, SCD4X_DEFAULT_ADDR # type: ignore
#
# _SCD40X_IMPORTED = True
# except ImportError:
# pass
if not _SCD40X_IMPORTED:
assert SCD4X is Any
try:
from ph4_sense.sensors.scd4x_mp import SCD4X, SCD4X_DEFAULT_ADDR # noqa: F811
_SCD40X_IMPORTED = True
except ImportError as e:
print("SCD40X import error:", e)
def scd4x_factory(bus, address: int = SCD4X_DEFAULT_ADDR, **kwargs) -> Optional[SCD4X]:
if not _SCD40X_IMPORTED:
return None
return SCD4X(bus, address, **kwargs)