Skip to content

Commit 23266c8

Browse files
committed
handling docs and readme TODOs, better docstrings.
1 parent 01a78b2 commit 23266c8

File tree

2 files changed

+177
-21
lines changed

2 files changed

+177
-21
lines changed

README.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,11 @@ or individual libraries can be installed using
4040

4141

4242

43-
.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the
44-
image from the assets folder in the PCB's GitHub repo.
45-
43+
Adafruit SPA06-003 Temperature + Pressure Sensor - STEMMA QT
4644
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/6420>`_
4745

4846
Installing from PyPI
4947
=====================
50-
.. note:: This library is not available on PyPI yet. Install documentation is included
51-
as a standard element. Stay tuned for PyPI availability!
52-
53-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
5448

5549
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
5650
PyPI <https://pypi.org/project/adafruit-circuitpython-spa06-003/>`_.
@@ -101,8 +95,25 @@ Or the following command to update an existing version:
10195
Usage Example
10296
=============
10397

104-
.. todo:: Add a quick, simple example. It and other examples should live in the
105-
examples folder and be included in docs/examples.rst.
98+
.. code-block:: python
99+
100+
import time
101+
102+
import board
103+
104+
from adafruit_spa06_003 import SPA06_003_I2C
105+
106+
i2c = board.I2C()
107+
spa = SPA06_003_I2C(i2c)
108+
109+
110+
while True:
111+
if spa.temperature_data_ready and spa.pressure_data_ready:
112+
print(f"Temperature: {spa.temperature} °C", end=" ")
113+
print(f"Pressure: {spa.pressure} hPa")
114+
115+
time.sleep(0.01)
116+
106117
107118
Documentation
108119
=============

adafruit_spa06_003.py

Lines changed: 157 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@
1616
1717
**Hardware:**
1818
19-
.. todo:: Add links to any specific hardware product page(s), or category page(s).
20-
Use unordered list & hyperlink rST inline format: "* `Link Text <url>`_"
19+
* `Adafruit SPA06-003 Temperature + Pressure Sensor - STEMMA QT <https://www.adafruit.com/product/6420>`_
2120
2221
**Software and Dependencies:**
2322
2423
* Adafruit CircuitPython firmware for the supported boards:
2524
https://circuitpython.org/downloads
2625
27-
.. todo:: Uncomment or remove the Bus Device and/or the Register library dependencies
28-
based on the library's use of either.
29-
30-
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
31-
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
26+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
3228
"""
3329

3430
import time
@@ -162,6 +158,122 @@ class SPA06_003_I2C:
162158
163159
:param busio.I2C i2c: I2C bus
164160
:param int address: I2C address
161+
162+
.. _measurement-rate-options:
163+
164+
Measurement Rate Options
165+
=========================
166+
167+
.. list-table::
168+
:header-rows: 1
169+
:widths: 35 15 50
170+
171+
* - Constant Name
172+
- Value
173+
- Description
174+
* - ``SPA06_003_RATE_1``
175+
- ``0x00``
176+
- 1 measurements per second
177+
* - ``SPA06_003_RATE_2``
178+
- ``0x01``
179+
- 2 measurements per second
180+
* - ``SPA06_003_RATE_4``
181+
- ``0x02``
182+
- 4 measurements per second
183+
* - ``SPA06_003_RATE_8``
184+
- ``0x03``
185+
- 8 measurements per second
186+
* - ``SPA06_003_RATE_16``
187+
- ``0x04``
188+
- 16 measurements per second
189+
* - ``SPA06_003_RATE_32``
190+
- ``0x05``
191+
- 32 measurements per second
192+
* - ``SPA06_003_RATE_64``
193+
- ``0x06``
194+
- 64 measurements per second
195+
* - ``SPA06_003_RATE_128``
196+
- ``0x07``
197+
- 128 measurements per second
198+
* - ``SPA06_003_RATE_25_16``
199+
- ``0x08``
200+
- 25/16 samples per second
201+
* - ``SPA06_003_RATE_25_8``
202+
- ``0x09``
203+
- 25/8 samples per second
204+
* - ``SPA06_003_RATE_25_4``
205+
- ``0x0A``
206+
- 25/4 samples per second
207+
* - ``SPA06_003_RATE_25_2``
208+
- ``0x0B``
209+
- 25/2 samples per second
210+
* - ``SPA06_003_RATE_25``
211+
- ``0x0C``
212+
- 25 samples per second
213+
* - ``SPA06_003_RATE_50``
214+
- ``0x0D``
215+
- 50 samples per second
216+
* - ``SPA06_003_RATE_100``
217+
- ``0x0E``
218+
- 100 samples per second
219+
* - ``SPA06_003_RATE_200``
220+
- ``0x0F``
221+
- 200 samples per second
222+
223+
.. _oversampling-rate-options:
224+
225+
Oversampling Rate Options
226+
=========================
227+
228+
.. list-table::
229+
:header-rows: 1
230+
:widths: 35 15 50
231+
232+
* - Constant Name
233+
- Value
234+
- Description
235+
* - ``SPA06_003_OVERSAMPLE_1``
236+
- ``0x00``
237+
- Single (no oversampling)
238+
* - ``SPA06_003_OVERSAMPLE_2``
239+
- ``0x01``
240+
- 2 times oversampling
241+
* - ``SPA06_003_OVERSAMPLE_4``
242+
- ``0x02``
243+
- 4 times oversampling
244+
* - ``SPA06_003_OVERSAMPLE_8``
245+
- ``0x03``
246+
- 8 times oversampling
247+
* - ``SPA06_003_OVERSAMPLE_16``
248+
- ``0x04``
249+
- 16 times oversampling
250+
* - ``SPA06_003_OVERSAMPLE_32``
251+
- ``0x05``
252+
- 32 times oversampling
253+
* - ``SPA06_003_OVERSAMPLE_64``
254+
- ``0x06``
255+
- 64 times oversampling
256+
* - ``SPA06_003_OVERSAMPLE_128``
257+
- ``0x07``
258+
- 128 times oversampling
259+
260+
Interrupt Polarity Options
261+
===========================
262+
263+
.. list-table::
264+
:header-rows: 1
265+
:widths: 35 15 50
266+
267+
* - Constant Name
268+
- Value
269+
- Description
270+
* - ``SPA06_003_INT_ACTIVE_LOW``
271+
- ``0x00``
272+
- Interrupt active low
273+
* - ``SPA06_003_INT_ACTIVE_HIGH``
274+
- ``0x01``
275+
- Interrupt active high
276+
165277
"""
166278

167279
chip_id = ROBits(8, SPA06_003_REG_ID, 0)
@@ -210,13 +322,15 @@ class SPA06_003_I2C:
210322
_pressure_shift_enabled = RWBit(SPA06_003_REG_CFG_REG, 2)
211323

212324
pressure_measure_rate = RWBits(4, SPA06_003_REG_PRS_CFG, 4)
213-
"""Pressure measurement rate. Must be one of the RATE constants."""
325+
"""Pressure measurement rate.
326+
Must be one of the :ref:`RATE constants. <measurement-rate-options>`"""
214327

215328
_temperature_oversampling = RWBits(3, SPA06_003_REG_TMP_CFG, 0)
216329
_temperature_shift_enabled = RWBit(SPA06_003_REG_CFG_REG, 3)
217330

218331
temperature_measure_rate = RWBits(4, SPA06_003_REG_TMP_CFG, 4)
219-
"""Temperature measurement rate. Must be one of the RATE constants."""
332+
"""Temperature measurement rate.
333+
Must be one of the :ref:`RATE constants. <measurement-rate-options>`"""
220334

221335
fifo_interrupt = RWBit(SPA06_003_REG_CFG_REG, 6)
222336
"""FIFO interrupt enable flag"""
@@ -228,7 +342,36 @@ class SPA06_003_I2C:
228342
"""Pressure interrupt enable flag"""
229343

230344
measurement_mode = RWBits(3, SPA06_003_REG_MEAS_CFG, 0)
231-
"""Measurement mode. Must be one of the MODE constants."""
345+
"""Measurement mode. Must be one of the MODE constants.
346+
347+
Measurement Mode Options
348+
========================
349+
350+
.. list-table::
351+
:header-rows: 1
352+
:widths: 45 15 40
353+
354+
* - Constant Name
355+
- Value
356+
- Description
357+
* - ``SPA06_003_MEAS_MODE_IDLE``
358+
- ``0x00``
359+
- Idle / Stop background measurement
360+
* - ``SPA06_003_MEAS_MODE_PRESSURE``
361+
- ``0x01``
362+
- Pressure measurement (Command Mode)
363+
* - ``SPA06_003_MEAS_MODE_TEMPERATURE``
364+
- ``0x02``
365+
- Temperature measurement (Command Mode)
366+
* - ``SPA06_003_MEAS_MODE_CONTINUOUS_PRESSURE``
367+
- ``0x05``
368+
- Continuous pressure measurement (Background Mode)
369+
* - ``SPA06_003_MEAS_MODE_CONTINUOUS_TEMPERATURE``
370+
- ``0x06``
371+
- Continuous temperature measurement (Background Mode)
372+
* - ``SPA06_003_MEAS_MODE_CONTINUOUS_BOTH``
373+
- ``0x07``
374+
- Continuous pressure and temperature measurement (Background Mode)"""
232375

233376
temperature_data_ready = ROBit(SPA06_003_REG_MEAS_CFG, 5)
234377
"""Temperature data ready flag"""
@@ -341,7 +484,8 @@ def pressure(self):
341484

342485
@property
343486
def pressure_oversampling(self):
344-
"""Pressure oversampling rate. Must be one of the OVERSAMPLE constants."""
487+
"""Pressure oversampling rate.
488+
Must be one of the :ref:`OVERSAMPLE constants. <oversampling-rate-options>`"""
345489
return self._pressure_oversampling
346490

347491
@pressure_oversampling.setter
@@ -354,7 +498,8 @@ def pressure_oversampling(self, new_value):
354498

355499
@property
356500
def temperature_oversampling(self):
357-
"""Temperature oversampling rate. Must be one of the OVERSAMPLE constants."""
501+
"""Temperature oversampling rate.
502+
Must be one of the :ref:`OVERSAMPLE constants. <oversampling-rate-options>`"""
358503
return self._temperature_oversampling
359504

360505
@temperature_oversampling.setter

0 commit comments

Comments
 (0)