@@ -114,21 +114,54 @@ class DataRate: # pylint: disable=too-few-public-methods
114
114
class LPS35HW : # pylint: disable=too-many-instance-attributes
115
115
"""Driver for the ST LPS35HW MEMS pressure sensor
116
116
117
- :param ~busio.I2C i2c_bus: The I2C bus the LPS34HW is connected to.
118
- :param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
119
- ``0x5c`` when the ``SDO`` pin is connected to Ground.
117
+ :param ~busio.I2C i2c_bus: The I2C bus the LPS35HW is connected to.
118
+ :param int address: The I2C device address for the sensor. Default is :const:`0x5d`
119
+ but will accept :const:`0x5c` when the ``SDO`` pin is connected to Ground.
120
+
121
+
122
+ **Quickstart: Importing and using the LPS35HW**
123
+
124
+ Here is an example of using the :class:`LPS35HW` class.
125
+ First you will need to import the libraries to use the sensor
126
+
127
+ .. code-block:: python
128
+
129
+ import board
130
+ import adafruit_lps35hw
131
+
132
+ Once this is done you can define your `board.I2C` object and define your sensor object
133
+
134
+ .. code-block:: python
135
+
136
+ i2c = board.I2C() # uses board.SCL and board.SDA
137
+ lps = adafruit_lps35hw.LPS35HW(i2c)
138
+
139
+ Now you have access to the :attr:`temperature` and :attr:`pressure` attributes.
140
+ Temperature is in Celsius and Pressure is in hPa.
141
+
142
+ .. code-block:: python
143
+
144
+ temperature = lps.temperature
145
+ pressure = lps.pressure
146
+
120
147
121
148
"""
122
149
123
150
data_rate = RWBits (3 , _CTRL_REG1 , 4 )
124
- """The rate at which the sensor measures ``pressure`` and ``temperature``. ``data_rate`` should
125
- be set to one of the values of ``adafruit_lps35hw.DataRate``. Note that setting ``data_rate``
126
- to ``DataRate.ONE_SHOT`` places the sensor into a low-power shutdown mode where measurements to
127
- update ``pressure`` and ``temperature`` are only taken when ``take_measurement`` is called."""
151
+ """The rate at which the sensor measures :attr:`pressure` and :attr:`temperature`.
152
+ ``data_rate`` should be set to one of the values of :meth:`adafruit_lps35hw.DataRate`.
153
+
154
+ .. note::
155
+ Setting ``data_rate`` to :const:`DataRate.ONE_SHOT` places the sensor
156
+ into a low-power shutdown mode where measurements to update
157
+ :attr:`pressure` and :attr:`temperature` are only taken
158
+ when :meth:`take_measurement` is called.
159
+
160
+ """
128
161
129
162
low_pass_enabled = RWBit (_CTRL_REG1 , 3 )
130
163
"""True if the low pass filter is enabled. Setting to `True` will reduce the sensor bandwidth
131
- from `` data_rate/2`` to `` data_rate/9` `, filtering out high-frequency noise."""
164
+ from :math:` data_rate/2` to :math:` data_rate/9`, filtering out high-frequency noise."""
132
165
133
166
_raw_temperature = UnaryStruct (_TEMP_OUT_L , "<h" )
134
167
_raw_pressure = ROBits (24 , _PRESS_OUT_XL , 0 , 3 )
@@ -181,7 +214,7 @@ def pressure(self):
181
214
182
215
@property
183
216
def temperature (self ):
184
- """The current temperature measurement in degrees C """
217
+ """The current temperature measurement in degrees Celsius """
185
218
return self ._raw_temperature / 100.0
186
219
187
220
def reset (self ):
@@ -192,26 +225,27 @@ def reset(self):
192
225
pass
193
226
194
227
def take_measurement (self ):
195
- """Update the value of ``pressure`` and ``temperature`` by taking a single measurement.
196
- Only meaningful if ``data_rate`` is set to ``ONE_SHOT``"""
228
+ """Update the value of :attr:`pressure` and :attr:`temperature`
229
+ by taking a single measurement. Only meaningful if ``data_rate``
230
+ is set to ``ONE_SHOT``"""
197
231
self ._one_shot = True
198
232
while self ._one_shot :
199
233
pass
200
234
201
235
def zero_pressure (self ):
202
- """Set the current pressure as zero and report the `` pressure` ` relative to it"""
236
+ """Set the current pressure as zero and report the :attr:` pressure` relative to it"""
203
237
self ._auto_zero = True
204
238
while self ._auto_zero :
205
239
pass
206
240
207
241
def reset_pressure (self ):
208
- """Reset `` pressure` ` to be reported as the measured absolute value"""
242
+ """Reset :attr:` pressure` to be reported as the measured absolute value"""
209
243
self ._reset_zero = True
210
244
211
245
@property
212
246
def pressure_threshold (self ):
213
- """The high presure threshold. Use `` high_threshold_enabled`` or ``high_threshold_enabled` `
214
- to use it"""
247
+ """The high pressure threshold. Use :attr:` high_threshold_enabled`
248
+ or :attr:`high_threshold_enabled` to use it"""
215
249
return self ._pressure_threshold / 16
216
250
217
251
@pressure_threshold .setter
@@ -231,8 +265,12 @@ def high_threshold_enabled(self, value):
231
265
232
266
@property
233
267
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**"""
268
+ """Set to `True` or `False` to enable or disable the low pressure threshold.
269
+
270
+ .. note::
271
+ The low pressure threshold only works in relative mode
272
+
273
+ """
236
274
return self ._interrupts_enabled and self ._interrupt_low
237
275
238
276
@low_threshold_enabled .setter
@@ -242,12 +280,14 @@ def low_threshold_enabled(self, value):
242
280
243
281
@property
244
282
def high_threshold_exceeded (self ):
245
- """Returns `True` if the pressure high threshold has been exceeded. Must be enabled by
246
- setting ``high_threshold_enabled`` to `True` and setting a ``pressure_threshold``."""
283
+ """Returns `True` if the pressure high threshold has been exceeded.
284
+ Must be enabled by setting :attr:`high_threshold_enabled` to `True`
285
+ and setting a :attr:`pressure_threshold`."""
247
286
return self ._pressure_high
248
287
249
288
@property
250
289
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``."""
290
+ """Returns `True` if the pressure low threshold has been exceeded.
291
+ Must be enabled by setting :attr:`high_threshold_enabled`
292
+ to `True` and setting a :attr:`pressure_threshold`."""
253
293
return self ._pressure_low
0 commit comments