Skip to content

Commit b5ac38b

Browse files
Merge pull request #12 from jposada202020/improving_docs
improving_docs
2 parents 657d539 + 7f72db6 commit b5ac38b

7 files changed

+49
-16
lines changed

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ Usage Example
6060
6161
import time
6262
import board
63-
import busio
6463
import adafruit_dps310
6564
66-
i2c = busio.I2C(board.SCL, board.SDA)
65+
i2c = board.I2C() # uses board.SCL and board.SDA
6766
6867
dps310 = adafruit_dps310.DPS310(i2c)
6968

adafruit_dps310.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Mode(CV):
114114

115115

116116
class Rate(CV):
117-
"""Options for `pressure_rate` and `temperature_rate`"""
117+
"""Options for :attr:`pressure_rate` and :attr:`temperature_rate`"""
118118

119119
pass
120120

@@ -134,7 +134,7 @@ class Rate(CV):
134134

135135

136136
class SampleCount(CV):
137-
"""Options for `temperature_oversample_count` and `pressure_oversample_count`"""
137+
"""Options for :attr:`temperature_oversample_count` and :attr:`pressure_oversample_count`"""
138138

139139
pass
140140

@@ -157,7 +157,31 @@ class DPS310:
157157
"""Library for the DPS310 Precision Barometric Pressure Sensor.
158158
159159
:param ~busio.I2C i2c_bus: The I2C bus the DPS310 is connected to.
160-
:param address: The I2C slave address of the sensor
160+
:param int address: The I2C device address. Defaults to :const:`0x77`
161+
162+
**Quickstart: Importing and using the DPS310**
163+
164+
Here is an example of using the :class:`DPS310` class.
165+
First you will need to import the libraries to use the sensor
166+
167+
.. code-block:: python
168+
169+
import board
170+
import adafruit_dps310
171+
172+
Once this is done you can define your `board.I2C` object and define your sensor object
173+
174+
.. code-block:: python
175+
176+
i2c = board.I2C() # uses board.SCL and board.SDA
177+
dps310 = adafruit_dps310.DPS310(i2c)
178+
179+
Now you have access to the :attr:`temperature` and :attr:`pressure` attributes.
180+
181+
.. code-block:: python
182+
183+
temperature = dps310.temperature
184+
pressure = dps310.pressure
161185
162186
"""
163187
# Register definitions
@@ -219,7 +243,7 @@ def __init__(self, i2c_bus, address=_DPS310_DEFAULT_ADDRESS):
219243
2088960,
220244
)
221245
self.sea_level_pressure = 1013.25
222-
"""Pressure in hectoPascals at sea level. Used to calibrate `altitude`."""
246+
"""Pressure in hectoPascals at sea level. Used to calibrate :attr:`altitude`."""
223247
self.initialize()
224248

225249
def initialize(self):
@@ -289,13 +313,13 @@ def pressure(self):
289313

290314
@property
291315
def altitude(self):
292-
"""The altitude based on the sea level pressure (`sea_level_pressure`) - which you must
293-
enter ahead of time)"""
316+
"""The altitude based on the sea level pressure (:attr:`sea_level_pressure`) -
317+
which you must enter ahead of time)"""
294318
return 44330 * (1.0 - math.pow(self.pressure / self.sea_level_pressure, 0.1903))
295319

296320
@property
297321
def temperature(self):
298-
"""The current temperature reading in degrees C"""
322+
"""The current temperature reading in degrees Celsius"""
299323
_scaled_rawtemp = self._raw_temperature / self._temp_scale
300324
_temperature = _scaled_rawtemp * self._c1 + self._c0 / 2.0
301325
return _temperature
@@ -375,7 +399,7 @@ def pressure_rate(self, value):
375399

376400
@property
377401
def pressure_oversample_count(self):
378-
"""The number of samples taken per pressure measurement. Must be a `SampleCount`"""
402+
"""The number of samples taken per pressure measurement. Must be a ``SampleCount``"""
379403
return self._pressure_osbits
380404

381405
@pressure_oversample_count.setter
@@ -400,7 +424,7 @@ def temperature_rate(self, value):
400424

401425
@property
402426
def temperature_oversample_count(self):
403-
"""The number of samples taken per temperature measurement. Must be a `SampleCount`"""
427+
"""The number of samples taken per temperature measurement. Must be a ``SampleCount``"""
404428
return self._temp_osbits
405429

406430
@temperature_oversample_count.setter

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
77
.. automodule:: adafruit_dps310
88
:members:
9+
:exclude-members: CV, SampleCount

docs/examples.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,13 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/dps310_simpletest.py
77
:caption: examples/dps310_simpletest.py
88
:linenos:
9+
10+
Lower Power Weather Station
11+
---------------------------
12+
13+
Example showing how to configure the sensor for continuous measurement with rates,
14+
sampling counts and mode optimized for low power
15+
16+
.. literalinclude:: ../examples/dps310_low_power_weather_station.py
17+
:caption: examples/dps310_low_power_weather_station.py
18+
:linenos:

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit DPS310 Precision Barometric Pressure / Altitude Sensor Learning Guide <https://learn.adafruit.com/adafruit-dps310-precision-barometric-pressure-sensor/python-circuitpython>
2627

2728
.. toctree::
2829
:caption: Related Products
2930

31+
Adafruit DPS310 Precision Barometric Pressure / Altitude Sensor <https://www.adafruit.com/product/4494>
3032

3133
.. toctree::
3234
:caption: Other Links

examples/dps310_low_power_weather_station.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
import time
1616
import board
17-
import busio
1817
import adafruit_dps310
1918

20-
i2c = busio.I2C(board.SCL, board.SDA)
19+
i2c = board.I2C() # uses board.SCL and board.SDA
2120

2221
dps310 = adafruit_dps310.DPS310(i2c)
2322

examples/dps310_simpletest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

44
import time
55
import board
6-
import busio
76
import adafruit_dps310
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
10-
8+
i2c = board.I2C() # uses board.SCL and board.SDA
119
dps310 = adafruit_dps310.DPS310(i2c)
1210

1311
while True:

0 commit comments

Comments
 (0)