Skip to content

improving_docs #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ To install in a virtual environment in your current project:
Usage Example
=============

.. code-block:: python
.. code-block:: python3

import time
import board
import busio
import adafruit_lps2x

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
# uncomment and comment out the line after to use with the LPS22
# lps = adafruit_lps2x.LPS22(i2c)
lps = adafruit_lps2x.LPS25(i2c)

while True:
print("Pressure: %.2f hPa" % lps.pressure)
print("Temperature: %.2f C" % lps.temperature)
Expand Down
49 changes: 31 additions & 18 deletions adafruit_lps2x.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@

**Hardware:**

* LPS25HB Breakout https://www.adafruit.com/products/4530
* Adafruit `LPS25 Pressure SensorLPS25HB Breakout
<https://www.adafruit.com/product/4530>`_ (Product ID: 4530)

* Adafruit `LPS22 Pressure Sensor LPS22HB Breakout
<https://www.adafruit.com/product/4633>`_ (Product ID: 4633)

**Software and Dependencies:**
* Adafruit CircuitPython firmware for the supported boards:

* Adafruit CircuitPython firmware for the supported boards:
https://circuitpythohn.org/downloads
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register

"""
__version__ = "0.0.0-auto.0"
Expand Down Expand Up @@ -68,7 +75,7 @@ class CV:

@classmethod
def add_values(cls, value_tuples):
"creates CV entires"
"""creates CV entries"""
cls.string = {}
cls.lsb = {}

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

@classmethod
def is_valid(cls, value):
"Returns true if the given value is a member of the CV"
"""Returns true if the given value is a member of the CV"""
return value in cls.string


Expand Down Expand Up @@ -122,8 +129,9 @@ class LPS2X: # pylint: disable=too-many-instance-attributes
"""Base class ST LPS2x family of pressure sensors

:param ~busio.I2C i2c_bus: The I2C bus the sensor is connected to.
:param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
``0x5c`` when the ``SDO`` pin is connected to Ground.
:param int address: The I2C device address for the sensor.
Default is :const:`0x5d` but will accept :const:`0x5c` when
the ``SDO`` pin is connected to Ground.

"""

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

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

@property
def temperature(self):
"""The current temperature measurement in degrees C"""
"""The current temperature measurement in degrees Celsius"""

raw_temperature = self._raw_temperature
return (
Expand All @@ -174,8 +182,9 @@ def temperature(self):

@property
def data_rate(self):
"""The rate at which the sensor measures ``pressure`` and ``temperature``. ``data_rate``
shouldbe set to one of the values of ``adafruit_lps2x.Rate``."""
"""The rate at which the sensor measures :attr:`pressure` and
:attr:`temperature`. :attr:`data_rate` should be set to one of
the values of :class:`adafruit_lps2x.Rate`"""
return self._data_rate

@data_rate.setter
Expand All @@ -190,8 +199,8 @@ class LPS25(LPS2X):
"""Library for the ST LPS25 pressure sensors

:param ~busio.I2C i2c_bus: The I2C bus the LPS25HB is connected to.
:param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
``0x5c`` when the ``SDO`` pin is connected to Ground.
:param int address: The I2C device address. Default is :const:`0x5d` but will accept
:const:`0x5c` when the ``SDO`` pin is connected to Ground.

"""

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

def initialize(self):
"""Configure the sensor with the default settings. For use after calling `reset()`"""
"""Configure the sensor with the default settings.
For use after calling :func:`LPS2X.reset`
"""
self.enabled = True
self.data_rate = Rate.LPS25_RATE_25_HZ # pylint:disable=no-member

Expand All @@ -230,8 +241,8 @@ class LPS22(LPS2X):
"""Library for the ST LPS22 pressure sensors

:param ~busio.I2C i2c_bus: The I2C bus the LPS22HB is connected to.
:param address: The I2C device address for the sensor. Default is ``0x5d`` but will accept
``0x5c`` when the ``SDO`` pin is connected to Ground.
:param address: The I2C device address. Default is :const:`0x5d` but will accept
:const:`0x5c` when the ``SDO`` pin is connected to Ground.

"""

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

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

# void configureInterrupt(bool activelow, bool opendrain, bool data_ready,
Expand Down
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

.. automodule:: adafruit_lps2x
:members:
:member-order: bysource
:exclude-members: CV
5 changes: 4 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ Table of Contents
.. toctree::
:caption: Tutorials

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

.. toctree::
:caption: Related Products

* LPS25HW Breakout <https://www.adafruit.com/products/4258>
Adafruit LPS22 Pressure Sensor <https://www.adafruit.com/product/4633>

Adafruit LPS25 Pressure Sensor <https://www.adafruit.com/products/4258>

.. toctree::
:caption: Other Links
Expand Down
4 changes: 2 additions & 2 deletions examples/lps2x_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import time
import board
import busio
import adafruit_lps2x

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C()
# uncomment and comment out the line after to use with the LPS22
# lps = adafruit_lps2x.LPS22(i2c)
lps = adafruit_lps2x.LPS25(i2c)

while True:
print("Pressure: %.2f hPa" % lps.pressure)
print("Temperature: %.2f C" % lps.temperature)
Expand Down