34
34
**Hardware:**
35
35
36
36
**Software and Dependencies:**
37
-
38
37
* Adafruit CircuitPython firmware for the supported boards:
39
38
https://github.com/adafruit/circuitpython/releases
40
39
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
@@ -105,19 +104,15 @@ class DataRate: # pylint: disable=too-few-public-methods
105
104
RATE_50_hz = const (0x04 )
106
105
RATE_75_hz = const (0x05 )
107
106
108
- class LPS35HW :
107
+ class LPS35HW : # pylint: disable=too-many-instance-attributes
109
108
"""Driver for the ST LPS35HW MEMS pressure sensor
110
109
111
110
:param ~busio.I2C i2c_bus: The I2C bus the INA260 is connected to.
112
- :param address: The I2C device address for the sensor. Default is ``0x5d``.
111
+ :param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
112
+ ``0x5c`` when the ``SDO`` pin is connected to Ground.
113
113
114
114
"""
115
115
116
-
117
- reset_pressure = RWBit (_INTERRUPT_CFG , 4 )
118
- """Reset ``pressure`` to be reported as the measured absolute value"""
119
-
120
-
121
116
data_rate = RWBits (3 , _CTRL_REG1 , 4 )
122
117
"""The rate at which the sensor measures ``pressure`` and ``temperature``. ``data_rate`` should
123
118
be set to one of the values of ``adafruit_lps35hw.DataRate``. Note that setting ``data_rate``
@@ -138,16 +133,17 @@ class LPS35HW:
138
133
_reset = RWBit (_CTRL_REG2 , 2 )
139
134
_one_shot = RWBit (_CTRL_REG2 , 0 )
140
135
141
- _interrupt_active_low = RWBit (_CTRL_REG3 , 7 )
142
- _interrupt_open_drain = RWBit (_CTRL_REG3 , 6 )
143
- _int_pin_on_high = RWBit (_CTRL_REG3 , 1 )
144
- _int_pin_on_low = RWBit (_CTRL_REG3 , 0 )
136
+ # registers for configuring INT pin behavior
137
+ _interrupt_cfg = UnaryStruct (_CTRL_REG3 , "<B" ) # to read all values for latching?
145
138
139
+ # INT status registers
146
140
_interrupt_active = RWBit (_INT_SOURCE , 2 )
147
141
_pressure_low = RWBit (_INT_SOURCE , 1 )
148
142
_pressure_high = RWBit (_INT_SOURCE , 0 )
149
143
150
144
_auto_zero = RWBit (_INTERRUPT_CFG , 5 )
145
+ _reset_zero = RWBit (_INTERRUPT_CFG , 4 )
146
+
151
147
_interrupts_enabled = RWBit (_INTERRUPT_CFG , 3 )
152
148
_interrupt_latch = RWBit (_INTERRUPT_CFG , 2 )
153
149
_interrupt_low = RWBit (_INTERRUPT_CFG , 1 )
@@ -158,7 +154,6 @@ class LPS35HW:
158
154
_chip_id = UnaryStruct (_WHO_AM_I , "<B" )
159
155
_pressure_threshold = UnaryStruct (_THS_P_L , "<H" )
160
156
161
- # def __init__(self, i2c_bus, address=0x5c):
162
157
def __init__ (self , i2c_bus , address = 0x5d ):
163
158
self .i2c_device = i2cdevice .I2CDevice (i2c_bus , address )
164
159
if self ._chip_id != 0xb1 :
@@ -187,7 +182,6 @@ def pressure(self):
187
182
@property
188
183
def temperature (self ):
189
184
"""The current temperature measurement in degrees C"""
190
-
191
185
return self ._raw_temperature / 100.0
192
186
193
187
def reset (self ):
@@ -210,13 +204,14 @@ def zero_pressure(self):
210
204
while self ._auto_zero :
211
205
pass
212
206
213
- # def reset_pressure(self):
214
- # """Reset ``pressure`` to be reported as the measured absolute value"""
215
- # self._reset_zero = True
207
+ def reset_pressure (self ):
208
+ """Reset ``pressure`` to be reported as the measured absolute value"""
209
+ self ._reset_zero = True
216
210
217
211
@property
218
212
def pressure_threshold (self ):
219
- """The high presure threshold. Use ``high_threshold_enabled`` to use it"""
213
+ """The high presure threshold. Use ``high_threshold_enabled`` or ``high_threshold_enabled``
214
+ to use it"""
220
215
return self ._pressure_threshold / 16
221
216
222
217
@pressure_threshold .setter
@@ -231,15 +226,28 @@ def high_threshold_enabled(self):
231
226
232
227
@high_threshold_enabled .setter
233
228
def high_threshold_enabled (self , value ):
234
- if value :
235
- self ._interrupts_enabled = True
236
- self ._interrupt_high = True
237
- else :
238
- self ._interrupts_enabled = False
239
- self ._interrupt_high = False
229
+ self ._interrupts_enabled = value
230
+ self ._interrupt_high = value
231
+
232
+ @property
233
+ def low_threshold_enabled (self ):
234
+ """Set to `True` or `False` to enable or disable the low pressure threshold. **Note the
235
+ low pressure threshold only works in relative mode**"""
236
+ return self ._interrupts_enabled and self ._interrupt_low
237
+
238
+ @low_threshold_enabled .setter
239
+ def low_threshold_enabled (self , value ):
240
+ self ._interrupts_enabled = value
241
+ self ._interrupt_low = value
240
242
241
243
@property
242
244
def high_threshold_exceeded (self ):
243
245
"""Returns `True` if the pressure high threshold has been exceeded. Must be enabled by
244
246
setting ``high_threshold_enabled`` to `True` and setting a ``pressure_threshold``."""
245
247
return self ._pressure_high
248
+
249
+ @property
250
+ def low_threshold_exceeded (self ):
251
+ """Returns `True` if the pressure low threshold has been exceeded. Must be enabled by
252
+ setting ``high_threshold_enabled`` to `True` and setting a ``pressure_threshold``."""
253
+ return self ._pressure_low
0 commit comments