Skip to content

Commit 1b406f5

Browse files
Merge pull request #7 from jposada202020/improving_docs
improving_docs
2 parents 8d94721 + 2abd4e9 commit 1b406f5

File tree

5 files changed

+42
-24
lines changed

5 files changed

+42
-24
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ To install in a virtual environment in your current project:
5454
Usage Example
5555
=============
5656

57-
.. code-block:: python
57+
.. code-block:: python3
5858
5959
import time
6060
import board
61-
import busio
6261
import adafruit_lps2x
6362
64-
i2c = busio.I2C(board.SCL, board.SDA)
63+
i2c = board.I2C()
6564
# uncomment and comment out the line after to use with the LPS22
6665
# lps = adafruit_lps2x.LPS22(i2c)
6766
lps = adafruit_lps2x.LPS25(i2c)
67+
6868
while True:
6969
print("Pressure: %.2f hPa" % lps.pressure)
7070
print("Temperature: %.2f C" % lps.temperature)

adafruit_lps2x.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@
1515
1616
**Hardware:**
1717
18-
* LPS25HB Breakout https://www.adafruit.com/products/4530
18+
* Adafruit `LPS25 Pressure SensorLPS25HB Breakout
19+
<https://www.adafruit.com/product/4530>`_ (Product ID: 4530)
20+
21+
* Adafruit `LPS22 Pressure Sensor LPS22HB Breakout
22+
<https://www.adafruit.com/product/4633>`_ (Product ID: 4633)
1923
2024
**Software and Dependencies:**
21-
* Adafruit CircuitPython firmware for the supported boards:
25+
26+
* Adafruit CircuitPython firmware for the supported boards:
2227
https://circuitpythohn.org/downloads
23-
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
24-
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
28+
29+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
30+
31+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
2532
2633
"""
2734
__version__ = "0.0.0-auto.0"
@@ -68,7 +75,7 @@ class CV:
6875

6976
@classmethod
7077
def add_values(cls, value_tuples):
71-
"creates CV entires"
78+
"""creates CV entries"""
7279
cls.string = {}
7380
cls.lsb = {}
7481

@@ -80,7 +87,7 @@ def add_values(cls, value_tuples):
8087

8188
@classmethod
8289
def is_valid(cls, value):
83-
"Returns true if the given value is a member of the CV"
90+
"""Returns true if the given value is a member of the CV"""
8491
return value in cls.string
8592

8693

@@ -122,8 +129,9 @@ class LPS2X: # pylint: disable=too-many-instance-attributes
122129
"""Base class ST LPS2x family of pressure sensors
123130
124131
:param ~busio.I2C i2c_bus: The I2C bus the sensor is connected to.
125-
:param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
126-
``0x5c`` when the ``SDO`` pin is connected to Ground.
132+
:param int address: The I2C device address for the sensor.
133+
Default is :const:`0x5d` but will accept :const:`0x5c` when
134+
the ``SDO`` pin is connected to Ground.
127135
128136
"""
129137

@@ -142,7 +150,7 @@ def __init__(self, i2c_bus, address=_LPS2X_DEFAULT_ADDRESS, chip_id=None):
142150
sleep(0.010) # delay 10ms for first reading
143151

144152
def initialize(self): # pylint: disable=no-self-use
145-
"""Configure the sensor with the default settings. For use after calling `reset()`"""
153+
"""Configure the sensor with the default settings. For use after calling :meth:`reset`"""
146154
raise RuntimeError(
147155
"LPS2X Base class cannot be instantiated directly. Use LPS22 or LPS25 instead"
148156
) # override in subclass
@@ -165,7 +173,7 @@ def pressure(self):
165173

166174
@property
167175
def temperature(self):
168-
"""The current temperature measurement in degrees C"""
176+
"""The current temperature measurement in degrees Celsius"""
169177

170178
raw_temperature = self._raw_temperature
171179
return (
@@ -174,8 +182,9 @@ def temperature(self):
174182

175183
@property
176184
def data_rate(self):
177-
"""The rate at which the sensor measures ``pressure`` and ``temperature``. ``data_rate``
178-
shouldbe set to one of the values of ``adafruit_lps2x.Rate``."""
185+
"""The rate at which the sensor measures :attr:`pressure` and
186+
:attr:`temperature`. :attr:`data_rate` should be set to one of
187+
the values of :class:`adafruit_lps2x.Rate`"""
179188
return self._data_rate
180189

181190
@data_rate.setter
@@ -190,8 +199,8 @@ class LPS25(LPS2X):
190199
"""Library for the ST LPS25 pressure sensors
191200
192201
:param ~busio.I2C i2c_bus: The I2C bus the LPS25HB is connected to.
193-
:param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
194-
``0x5c`` when the ``SDO`` pin is connected to Ground.
202+
:param int address: The I2C device address. Default is :const:`0x5d` but will accept
203+
:const:`0x5c` when the ``SDO`` pin is connected to Ground.
195204
196205
"""
197206

@@ -218,7 +227,9 @@ def __init__(self, i2c_bus, address=_LPS2X_DEFAULT_ADDRESS):
218227
# self._inc_spi_flag = 0x40
219228

220229
def initialize(self):
221-
"""Configure the sensor with the default settings. For use after calling `reset()`"""
230+
"""Configure the sensor with the default settings.
231+
For use after calling :func:`LPS2X.reset`
232+
"""
222233
self.enabled = True
223234
self.data_rate = Rate.LPS25_RATE_25_HZ # pylint:disable=no-member
224235

@@ -230,8 +241,8 @@ class LPS22(LPS2X):
230241
"""Library for the ST LPS22 pressure sensors
231242
232243
:param ~busio.I2C i2c_bus: The I2C bus the LPS22HB is connected to.
233-
:param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
234-
``0x5c`` when the ``SDO`` pin is connected to Ground.
244+
:param address: The I2C device address. Default is :const:`0x5d` but will accept
245+
:const:`0x5c` when the ``SDO`` pin is connected to Ground.
235246
236247
"""
237248

@@ -256,7 +267,9 @@ def __init__(self, i2c_bus, address=_LPS2X_DEFAULT_ADDRESS):
256267
self._temp_offset = 0
257268

258269
def initialize(self):
259-
"""Configure the sensor with the default settings. For use after calling `reset()`"""
270+
"""Configure the sensor with the default settings.
271+
For use after calling :func:`LPS2X.reset`
272+
"""
260273
self.data_rate = Rate.LPS22_RATE_75_HZ # pylint:disable=no-member
261274

262275
# void configureInterrupt(bool activelow, bool opendrain, bool data_ready,

docs/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
77
.. automodule:: adafruit_lps2x
88
:members:
9+
:member-order: bysource
10+
:exclude-members: CV

docs/index.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit LPS2X Pressure Sensor Learning Guide <https://learn.adafruit.com/adafruit-lps25-pressure-sensor>
2627

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

30-
* LPS25HW Breakout <https://www.adafruit.com/products/4258>
31+
Adafruit LPS22 Pressure Sensor <https://www.adafruit.com/product/4633>
32+
33+
Adafruit LPS25 Pressure Sensor <https://www.adafruit.com/products/4258>
3134

3235
.. toctree::
3336
:caption: Other Links

examples/lps2x_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

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

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C()
109
# uncomment and comment out the line after to use with the LPS22
1110
# lps = adafruit_lps2x.LPS22(i2c)
1211
lps = adafruit_lps2x.LPS25(i2c)
12+
1313
while True:
1414
print("Pressure: %.2f hPa" % lps.pressure)
1515
print("Temperature: %.2f C" % lps.temperature)

0 commit comments

Comments
 (0)