File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 38
38
from digitalio import Direction
39
39
from micropython import const
40
40
41
+ try :
42
+ from typing import Optional
43
+ from busio import I2C
44
+ from digitalio import DigitalInOut # pylint: disable=ungrouped-imports
45
+ except ImportError :
46
+ pass
47
+
41
48
_MPRLS_DEFAULT_ADDR = const (0x18 )
42
49
43
50
@@ -80,13 +87,13 @@ class MPRLS:
80
87
81
88
def __init__ (
82
89
self ,
83
- i2c_bus ,
90
+ i2c_bus : I2C ,
84
91
* ,
85
- addr = _MPRLS_DEFAULT_ADDR ,
86
- reset_pin = None ,
87
- eoc_pin = None ,
88
- psi_min = 0 ,
89
- psi_max = 25
92
+ addr : int = _MPRLS_DEFAULT_ADDR ,
93
+ reset_pin : Optional [ DigitalInOut ] = None ,
94
+ eoc_pin : Optional [ DigitalInOut ] = None ,
95
+ psi_min : int = 0 ,
96
+ psi_max : int = 25
90
97
):
91
98
# Init I2C
92
99
self ._i2c = I2CDevice (i2c_bus , addr )
@@ -113,11 +120,11 @@ def __init__(
113
120
# That's pretty much it, there's no ID register :(
114
121
115
122
@property
116
- def pressure (self ):
123
+ def pressure (self ) -> float :
117
124
"""The measured pressure, in hPa"""
118
125
return self ._read_data ()
119
126
120
- def _read_data (self ):
127
+ def _read_data (self ) -> float :
121
128
"""Read the status & 24-bit data reading"""
122
129
self ._buffer [0 ] = 0xAA
123
130
self ._buffer [1 ] = 0
You can’t perform that action at this time.
0 commit comments