Skip to content

Commit f8a5357

Browse files
authored
Merge pull request #3 from jposada202020/improving_docs
improving_docs. No functionality added
2 parents 386283f + a861036 commit f8a5357

File tree

8 files changed

+106
-34
lines changed

8 files changed

+106
-34
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@ To install in a virtual environment in your current project:
5959
Usage Example
6060
=============
6161

62-
.. code-block:: python
62+
.. code-block:: python3
6363
6464
import time
6565
import board
66-
import busio
6766
import adafruit_lis331
6867
69-
i2c = busio.I2C(board.SCL, board.SDA)
68+
i2c = board.I2C() # uses board.SCL and board.SDA
7069
lis = adafruit_lis331.LIS331(i2c)
7170
7271
while True:

adafruit_lis331.py

Lines changed: 80 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
1717
**Hardware:**
1818
19-
* `Adafruit LIS331HH Breakout <https://www.adafruit.com/products/45XX>`_
20-
* `Adafruit H3LIS331 Breakout <https://www.adafruit.com/products/45XX>`_
19+
* `Adafruit LIS331HH Breakout <https://www.adafruit.com/products/4626>`_
20+
* `Adafruit H3LIS331 Breakout <https://www.adafruit.com/products/4627>`_
2121
2222
**Software and Dependencies:**
2323
2424
* Adafruit CircuitPython firmware for the supported boards:
25-
https://github.com/adafruit/circuitpython/releases
26-
27-
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
28-
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
25+
https://circuitpython.org/downloads
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
2928
"""
3029

3130
__version__ = "0.0.0-auto.0"
@@ -61,12 +60,16 @@ class ROByteArray:
6160
Values are FixNums that map to the values in the defined struct. See struct
6261
module documentation for struct format string and its possible value types.
6362
64-
.. note:: This assumes the device addresses correspond to 8-bit bytes. This is not suitable for
65-
devices with registers of other widths such as 16-bit.
63+
.. note::
64+
This assumes the device addresses correspond to 8-bit bytes.
65+
This is not suitable for devices with registers of other
66+
widths such as 16-bit.
6667
6768
:param int register_address: The register address to begin reading the array from
68-
:param str struct_format: The struct format string for this register.
69+
:param str format_str: The struct format string for this register.
6970
:param int count: Number of elements in the array
71+
72+
7073
"""
7174

7275
def __init__( # pylint: disable=too-many-arguments
@@ -203,7 +206,7 @@ class LIS331:
203206
**Cannot be instantiated directly**
204207
205208
:param ~busio.I2C i2c_bus: The I2C bus the LIS331 is connected to.
206-
:param address: The I2C slave address of the sensor
209+
:param address: The I2C device address. Defaults to :const:`0x18`
207210
208211
"""
209212

@@ -261,6 +264,7 @@ def hpf_reference(self):
261264
is a signed 8-bit number from -128 to 127. The value of each increment of 1 depends on the
262265
currently set measurement range and is approximate:
263266
#pylint: disable=line-too-long
267+
264268
+-------------------------------------------------------------+-------------------------------+
265269
| Range | Incremental value (LSB value) |
266270
+-------------------------------------------------------------+-------------------------------+
@@ -270,6 +274,7 @@ def hpf_reference(self):
270274
+-------------------------------------------------------------+-------------------------------+
271275
| ``LIS331HHRange.RANGE_24G`` or ``H3LIS331Range.RANGE_400G`` | ~63mg |
272276
+-------------------------------------------------------------+-------------------------------+
277+
273278
#pylint: enable=line-too-long
274279
"""
275280

@@ -282,9 +287,10 @@ def hpf_reference(self, reference_value):
282287
self._reference_value = reference_value
283288

284289
def zero_hpf(self):
285-
"""When the high-pass filter is enabled with ``use_reference=False``, calling ``zero_hpf``
286-
will set all measurements to zero immediately, avoiding the normal settling time seen when
287-
using the high-pass filter without a ``hpf_reference``
290+
"""When the high-pass filter is enabled with ``use_reference=False``,
291+
calling :meth:`zero_hpf` will set all measurements to zero immediately,
292+
avoiding the normal settling time seen when using the high-pass filter
293+
without a :meth:`hpf_reference`
288294
"""
289295
self._zero_hpf # pylint: disable=pointless-statement
290296

@@ -294,12 +300,14 @@ def enable_hpf(
294300
"""Enable or disable the high-pass filter.
295301
296302
:param enabled: Enable or disable the filter. Default is `True` to enable
297-
:param ~RateDivisor cutoff: A `RateDivisor` to set the high-pass cutoff frequency. Default\
298-
is ``RateDivisor.ODR_DIV_50``. See ``RateDivisor`` for more information
303+
:param ``RateDivisor`` cutoff: A ``RateDivisor`` to set the high-pass
304+
cutoff frequency. Default is ``RateDivisor.ODR_DIV_50``. See ``RateDivisor``
305+
for more information
299306
:param use_reference: Determines if the filtered measurements are offset by a reference\
300-
value. Default is false.
307+
value. Default is false.
301308
302-
See section **4** of the LIS331DLH application note for more information `LIS331DLH application\
309+
See section **4** of the LIS331DLH application note for more information
310+
`LIS331DLH application
303311
note for more information <https://www.st.com/content/ccc/resource/technical/document/\
304312
application_note/b5/8e/58/69/cb/87/45/55/CD00215823.pdf/files/CD00215823.pdf/jcr:content/\
305313
translations/en.CD00215823.pdf>`_
@@ -311,7 +319,7 @@ def enable_hpf(
311319

312320
@property
313321
def data_rate(self):
314-
"""Select the rate at which the accelerometer takes measurements. Must be a `Rate`"""
322+
"""Select the rate at which the accelerometer takes measurements. Must be a ``Rate``"""
315323
return self._cached_data_rate
316324

317325
@data_rate.setter
@@ -330,8 +338,8 @@ def data_rate(self, new_rate_bits):
330338

331339
@property
332340
def mode(self):
333-
"""The `Mode` power mode that the sensor is set to, as determined by the current
334-
`data_rate`. To set the mode, use `data_rate` and the approprite `Rate`"""
341+
"""The :attr:`Mode` power mode that the sensor is set to, as determined by the current
342+
`data_rate`. To set the mode, use `data_rate` and the appropriate ``Rate``"""
335343
mode_bits = self._mode_and_rate()[0]
336344
return mode_bits
337345

@@ -348,7 +356,7 @@ def _mode_and_rate(self, data_rate=None):
348356
@property
349357
def range(self):
350358
"""Adjusts the range of values that the sensor can measure, Note that larger ranges will be
351-
less accurate. Must be a `H3LIS331Range` or `LIS331HHRange`"""
359+
less accurate. Must be a ``H3LIS331Range`` or ``LIS331HHRange``"""
352360
return self._range_bits
353361

354362
@range.setter
@@ -363,7 +371,7 @@ def range(self, new_range):
363371

364372
@property
365373
def acceleration(self):
366-
"""The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2."""
374+
"""The x, y, z acceleration values returned in a 3-tuple and are in :math:`m / s ^ 2`."""
367375

368376
raw_acceleration_bytes = self._raw_acceleration
369377

@@ -385,7 +393,30 @@ class LIS331HH(LIS331):
385393
"""Driver for the LIS331HH 3-axis high-g accelerometer.
386394
387395
:param ~busio.I2C i2c_bus: The I2C bus the LIS331 is connected to.
388-
:param address: The I2C slave address of the sensor
396+
:param address: The I2C device address. Defaults to :const:`0x18`
397+
398+
**Quickstart: Importing and using the device**
399+
400+
Here is an example of using the :class:`LIS331` class.
401+
First you will need to import the libraries to use the sensor
402+
403+
.. code-block:: python
404+
405+
import board
406+
import adafruit_lis331
407+
408+
Once this is done you can define your `board.I2C` object and define your sensor object
409+
410+
.. code-block:: python
411+
412+
i2c = board.I2C() # uses board.SCL and board.SDA
413+
lis = adafruit_lis331.LIS331HH(i2c)
414+
415+
Now you have access to the :attr:`acceleration` attribute
416+
417+
.. code-block:: python
418+
419+
acceleration = lis.acceleration
389420
390421
"""
391422

@@ -401,7 +432,32 @@ class H3LIS331(LIS331):
401432
"""Driver for the H3LIS331 3-axis high-g accelerometer.
402433
403434
:param ~busio.I2C i2c_bus: The I2C bus the LIS331 is connected to.
404-
:param address: The I2C slave address of the sensor
435+
:param address: The I2C slave address of the sensor. Defaults to :const:`0x18`
436+
437+
**Quickstart: Importing and using the device**
438+
439+
Here is an example of using the :class:`LIS331` class.
440+
First you will need to import the libraries to use the sensor
441+
442+
.. code-block:: python
443+
444+
import board
445+
import adafruit_lis331
446+
447+
Once this is done you can define your `board.I2C` object and define your sensor object
448+
449+
.. code-block:: python
450+
451+
i2c = board.I2C() # uses board.SCL and board.SDA
452+
lis = adafruit_lis331.H3LIS331(i2c)
453+
454+
Now you have access to the :attr:`acceleration` attribute
455+
456+
.. code-block:: python
457+
458+
acceleration = lis.acceleration
459+
460+
405461
406462
"""
407463

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_lis331
88
:members:
9+
:exclude-members: ROByteArray, CV, RateDivisor, Frequency, Mode, Rate, H3LIS331Range, LIS331HHRange
10+
:member-order: bysource

docs/examples.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,21 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/lis331_simpletest.py
77
:caption: examples/lis331_simpletest.py
88
:linenos:
9+
10+
Low Pass Filter
11+
---------------
12+
13+
Example showing a low pass filter example
14+
15+
.. literalinclude:: ../examples/lis331_low_pass_filter.py
16+
:caption: examples/lis331_low_pass_filter.py
17+
:linenos:
18+
19+
High Pass Filter
20+
----------------
21+
22+
Example showing a high pass filter example
23+
24+
.. literalinclude:: ../examples/lis331_high_pass_filter.py
25+
:caption: examples/lis331_high_pass_filter.py
26+
:linenos:

docs/index.rst

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

26-
26+
Adafruit LIS331HH 3-axis Accelerometer Breakout Learning Guide <https://learn.adafruit.com/adafruit-h3lis331-and-lis331hh-high-g-3-axis-accelerometers/overview>
2727

2828
.. toctree::
2929
:caption: Related Products

examples/lis331_high_pass_filter.py

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

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

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
109
# un-comment the sensor you are using
1110
# lis = H3LIS331(i2c)
1211
lis = adafruit_lis331.LIS331HH(i2c)

examples/lis331_low_pass_filter.py

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

44
import time
55
import board
6-
import busio
76
from adafruit_lis331 import LIS331HH, Rate, Frequency
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
109

1110
# un-comment the sensor you are using
1211
# lis = H3LIS331(i2c)

examples/lis331_simpletest.py

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

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

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
109
lis = adafruit_lis331.LIS331HH(i2c)
1110

1211
while True:

0 commit comments

Comments
 (0)