From a63b671452f5f075b89c37eff85d28d151a0b84a Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sun, 25 Apr 2021 14:05:09 -0400 Subject: [PATCH 1/2] improving_docs --- .gitignore | 1 + README.rst | 21 +++++++++--------- adafruit_mprls.py | 42 ++++++++++++++++++++++++++++++------ docs/index.rst | 4 ++++ examples/mprls_simpletest.py | 3 +-- 5 files changed, 51 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index ced7313..9bfdd9d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ _build *.pyc .env bundles +.idea diff --git a/README.rst b/README.rst index d429b65..541045a 100644 --- a/README.rst +++ b/README.rst @@ -54,22 +54,21 @@ 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_mprls + import time + import board + import adafruit_mprls - i2c = busio.I2C(board.SCL, board.SDA) + i2c = board.I2C() - # Simplest use, connect to default over I2C - mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25) + # Simplest use, connect to default over I2C + mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25) + while True: + print((mpr.pressure,)) + time.sleep(1) - while True: - print((mpr.pressure,)) - time.sleep(1) Contributing ============ diff --git a/adafruit_mprls.py b/adafruit_mprls.py index 2eb3d7a..0263e70 100644 --- a/adafruit_mprls.py +++ b/adafruit_mprls.py @@ -15,10 +15,13 @@ **Hardware:** +* Adafruit `Adafruit MPRLS Ported Pressure Sensor Breakout + `_ (Product ID: 3965) + **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: - https://github.com/adafruit/circuitpython/releases + https://circuitpython.org/downloads * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice @@ -41,12 +44,37 @@ class MPRLS: """ Driver base for the MPRLS pressure sensor - :param i2c_bus: The `busio.I2C` object to use. This is the only required parameter. - :param int addr: The optional I2C address, defaults to 0x18 - :param microcontroller.Pin reset_pin: Optional digitalio pin for hardware resetting - :param microcontroller.Pin eoc_pin: Optional digitalio pin for getting End Of Conversion signal - :param float psi_min: The minimum pressure in PSI, defaults to 0 - :param float psi_max: The maximum pressure in PSI, defaults to 25 + + :param ~busio.I2C i2c_bus: The I2C bus the MPRLS is connected to + :param int addr: The I2C device address. Defaults to :const:`0x18` + :param ~microcontroller.Pin reset_pin: Optional ``digitalio.pin`` for hardware resetting + :param ~microcontroller.Pin eoc_pin: Optional ``digitalio pin`` for getting End Of Conversion signal + :param float psi_min: The minimum pressure in PSI, defaults to :const:`0` + :param float psi_max: The maximum pressure in PSI, defaults to :const:`25` + + **Quickstart: Importing and using the MPRLS** + + Here is an example of using the :class:`MPRLS` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + import adafruit_mprls + + Once this is done you can define your `board.I2C` object and define your sensor object + + .. code-block:: python + + i2c = board.I2C() # uses board.SCL and board.SDA + mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25) + + Now you have access to the :attr:`pressure` attribute + + .. code-block:: python + + pressure = mpr.pressure + """ def __init__( diff --git a/docs/index.rst b/docs/index.rst index 721e6e3..6b56f34 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,9 +23,13 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit MPRLS Ported Pressure Sensor Breakout - 0 to 25 PSI Learning Guide + .. toctree:: :caption: Related Products + Adafruit MPRLS Ported Pressure Sensor Breakout - 0 to 25 PSI + .. toctree:: :caption: Other Links diff --git a/examples/mprls_simpletest.py b/examples/mprls_simpletest.py index b82d2ce..ad3c065 100644 --- a/examples/mprls_simpletest.py +++ b/examples/mprls_simpletest.py @@ -3,10 +3,9 @@ import time import board -import busio import adafruit_mprls -i2c = busio.I2C(board.SCL, board.SDA) +i2c = board.I2C() # Simplest use, connect to default over I2C mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25) From d27719e7e8e3b40b71ccedf8a5541ef8b3da9912 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sun, 25 Apr 2021 14:12:12 -0400 Subject: [PATCH 2/2] format-long_line --- adafruit_mprls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_mprls.py b/adafruit_mprls.py index 0263e70..d1fe47f 100644 --- a/adafruit_mprls.py +++ b/adafruit_mprls.py @@ -48,7 +48,8 @@ class MPRLS: :param ~busio.I2C i2c_bus: The I2C bus the MPRLS is connected to :param int addr: The I2C device address. Defaults to :const:`0x18` :param ~microcontroller.Pin reset_pin: Optional ``digitalio.pin`` for hardware resetting - :param ~microcontroller.Pin eoc_pin: Optional ``digitalio pin`` for getting End Of Conversion signal + :param ~microcontroller.Pin eoc_pin: Optional ``digitalio pin`` + for getting End Of Conversion signal :param float psi_min: The minimum pressure in PSI, defaults to :const:`0` :param float psi_max: The maximum pressure in PSI, defaults to :const:`25`