Skip to content

Commit 0a51775

Browse files
authored
Merge pull request #40 from jposada202020/improving_docs
improving_docs
2 parents 3c0bf24 + 24539d6 commit 0a51775

15 files changed

+238
-69
lines changed

README.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@ To install in a virtual environment in your current project:
6060
6161
Usage Example
6262
=============
63-
.. code-block:: python
63+
.. code-block:: python3
6464
6565
import time
6666
import board
67-
import busio
6867
from adafruit_lsm6ds.lsm6dsox import LSM6DSOX
6968
70-
i2c = busio.I2C(board.SCL, board.SDA)
71-
69+
i2c = board.I2C() # uses board.SCL and board.SDA
7270
sox = LSM6DSOX(i2c)
7371
7472
while True:

adafruit_lsm6ds/__init__.py

+29-30
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,40 @@
3636
3737
**Hardware:**
3838
39-
* Adafruit LSM6DSOX Breakout <https://www.adafruit.com/products/4438>
39+
* Adafruit `LSM6DSOX 6 DoF Accelerometer and Gyroscope
40+
<https://www.adafruit.com/product/4438>`_
4041
41-
* Adafruit ISM330DHCX Breakout <https://www.adafruit.com/product/4502>
42+
* Adafruit `ISM330DHCX - 6 DoF IMU - Accelerometer and Gyroscope
43+
<https://www.adafruit.com/product/4502>`_
4244
43-
* Adafruit LSM6DSO32 Breakout <https://www.adafruit.com/product/4692>
45+
* Adafruit `LSM6DSO32 6-DoF Accelerometer and Gyroscope
46+
<https://www.adafruit.com/product/4692>`_
4447
45-
* Adafruit LSM6DS33 Breakout <https://www.adafruit.com/product/4480>
48+
* Adafruit `LSM6DS33 6-DoF Accel + Gyro IMU
49+
<https://www.adafruit.com/product/4480>`_
4650
47-
* Adafruit ISM330DHCX + LIS3MDL FEATHERWING <https://www.adafruit.com/product/4569>
51+
* Adafruit `ISM330DHCX + LIS3MDL FeatherWing - High Precision 9-DoF IMU
52+
<https://www.adafruit.com/product/4569>`_
4853
49-
* Adafruit LSM6DSOX + LIS3MDL - 9 DOF IMU Breakout <https://www.adafruit.com/product/4517>
54+
* Adafruit `LSM6DSOX + LIS3MDL - Precision 9 DoF IMU
55+
<https://www.adafruit.com/product/4517>`_
5056
51-
* Adafruit LSM6DS33 + LIS3MDL - 9 DOF IMU Breakout <https://www.adafruit.com/product/4485>
57+
* Adafruit `LSM6DS33 + LIS3MDL - 9 DoF IMU with Accel / Gyro / Mag
58+
<https://www.adafruit.com/product/4485>`_
59+
60+
* Adafruit `LSM6DSOX + LIS3MDL FeatherWing - Precision 9-DoF IMU
61+
<https://www.adafruit.com/product/4565>`_
5262
53-
* Adafruit LSM6DSOX + LIS3MDL 9 DOF IMU FeatherWing <https://www.adafruit.com/product/4565>
5463
5564
**Software and Dependencies:**
5665
5766
* Adafruit CircuitPython firmware for the supported boards:
58-
https://github.com/adafruit/circuitpython/releases
59-
67+
https://circuitpython.org/downloads
68+
* Adafruit's Bus Device library:
69+
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
70+
* Adafruit's Register library:
71+
https://github.com/adafruit/Adafruit_CircuitPython_Register
6072
61-
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
62-
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
6373
"""
6474

6575
__version__ = "0.0.0-auto.0"
@@ -92,7 +102,7 @@ def add_values(cls, value_tuples):
92102

93103
@classmethod
94104
def is_valid(cls, value):
95-
"Returns true if the given value is a member of the CV"
105+
"""Returns true if the given value is a member of the CV"""
96106
return value in cls.string
97107

98108

@@ -164,7 +174,8 @@ class LSM6DS: # pylint: disable=too-many-instance-attributes
164174
"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
165175
166176
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to.
167-
:param address: The I2C address of the sensor
177+
:param int address: TThe I2C device address. Defaults to :const:`0x6A`
178+
168179
"""
169180

170181
# ROUnaryStructs:
@@ -173,8 +184,6 @@ class LSM6DS: # pylint: disable=too-many-instance-attributes
173184
# Structs
174185
_raw_accel_data = Struct(_LSM6DS_OUTX_L_A, "<hhh")
175186
_raw_gyro_data = Struct(_LSM6DS_OUTX_L_G, "<hhh")
176-
_raw_temp_data = Struct(_LSM6DS_OUT_TEMP_L, "<bb")
177-
178187
# RWBits:
179188

180189
_accel_range = RWBits(2, _LSM6DS_CTRL1_XL, 2)
@@ -249,16 +258,6 @@ def _add_accel_ranges():
249258
)
250259
)
251260

252-
@property
253-
def temperature(self):
254-
"""The temperature, in degrees Celsius."""
255-
raw_temp_data = self._raw_temp_data
256-
257-
temperature_raw = raw_temp_data[0] | (raw_temp_data[1] << 8)
258-
temperature_c = temperature_raw / 16.0 + 25.0
259-
260-
return temperature_c
261-
262261
@property
263262
def acceleration(self):
264263
"""The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2."""
@@ -290,7 +289,7 @@ def _scale_gyro_data(self, raw_measurement):
290289
@property
291290
def accelerometer_range(self):
292291
"""Adjusts the range of values that the sensor can measure, from +/- 2G to +/-16G
293-
Note that larger ranges will be less accurate. Must be an `AccelRange`"""
292+
Note that larger ranges will be less accurate. Must be an ``AccelRange``"""
294293
return self._cached_accel_range
295294

296295
# pylint: disable=no-member
@@ -305,7 +304,7 @@ def accelerometer_range(self, value):
305304
@property
306305
def gyro_range(self):
307306
"""Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 2000
308-
degrees/s. Note that larger ranges will be less accurate. Must be a `GyroRange`."""
307+
degrees/s. Note that larger ranges will be less accurate. Must be a ``GyroRange``."""
309308
return self._cached_gyro_range
310309

311310
@gyro_range.setter
@@ -329,7 +328,7 @@ def _set_gyro_range(self, value):
329328

330329
@property
331330
def accelerometer_data_rate(self):
332-
"""Select the rate at which the accelerometer takes measurements. Must be a `Rate`"""
331+
"""Select the rate at which the accelerometer takes measurements. Must be a ``Rate``"""
333332
return self._accel_data_rate
334333

335334
@accelerometer_data_rate.setter
@@ -343,7 +342,7 @@ def accelerometer_data_rate(self, value):
343342

344343
@property
345344
def gyro_data_rate(self):
346-
"""Select the rate at which the gyro takes measurements. Must be a `Rate`"""
345+
"""Select the rate at which the gyro takes measurements. Must be a ``Rate``"""
347346
return self._gyro_data_rate
348347

349348
@gyro_data_rate.setter

adafruit_lsm6ds/ism330dhcx.py

+33-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44
"""
5-
This module provides the ISM330DHCX subclass of LSM6DS for using ISM330DHCX sensors.
5+
This module provides the `adafruit_lsm6ds.ism330dhcx` subclass of LSM6DS sensors
6+
==================================================================================
67
"""
78
from time import sleep
89
from . import LSM6DS, LSM6DS_DEFAULT_ADDRESS, GyroRange, RWBit, const
@@ -12,10 +13,37 @@
1213

1314
class ISM330DHCX(LSM6DS): # pylint: disable=too-many-instance-attributes
1415

15-
"""Driver for the LSM6DS33 6-axis accelerometer and gyroscope.
16+
"""Driver for the ISM330DHCX 6-axis accelerometer and gyroscope.
17+
18+
:param ~busio.I2C i2c_bus: The I2C bus the device is connected to.
19+
:param int address: The I2C device address. Defaults to :const:`0x6A`
20+
21+
22+
**Quickstart: Importing and using the device**
23+
24+
Here is an example of using the :class:`ISM330DHCX` class.
25+
First you will need to import the libraries to use the sensor
26+
27+
.. code-block:: python
28+
29+
import board
30+
from adafruit_lsm6ds.ism330dhcx import ISM330DHCX
31+
32+
Once this is done you can define your `board.I2C` object and define your sensor object
33+
34+
.. code-block:: python
35+
36+
i2c = board.I2C() # uses board.SCL and board.SDA
37+
sensor = ISM330DHCX(i2c)
38+
39+
Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes
40+
41+
.. code-block:: python
42+
43+
acc_x, acc_y, acc_z = sensor.acceleration
44+
gyro_x, gyro_z, gyro_z = sensor.gyro
45+
1646
17-
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to.
18-
:param address: The I2C address of the sensor
1947
"""
2048

2149
CHIP_ID = 0x6B
@@ -40,7 +68,7 @@ def __init__(self, i2c_bus, address=LSM6DS_DEFAULT_ADDRESS):
4068
@property
4169
def gyro_range(self):
4270
"""Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 4000
43-
degrees/s. Note that larger ranges will be less accurate. Must be a `GyroRange`. 4000 DPS
71+
degrees/s. Note that larger ranges will be less accurate. Must be a ``GyroRange``. 4000 DPS
4472
is only available for the ISM330DHCX"""
4573
return self._cached_gyro_range
4674

adafruit_lsm6ds/lsm6ds33.py

+29-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44
"""
5-
This module provides the LSM6DS33 subclass of LSM6DS for using LSM6DS33 sensors.
5+
This module provides the `adafruit_lsm6ds.lsm6ds33` subclass of LSM6DS sensors
6+
===============================================================================
67
"""
78
from . import LSM6DS
89

@@ -12,7 +13,33 @@ class LSM6DS33(LSM6DS): # pylint: disable=too-many-instance-attributes
1213
"""Driver for the LSM6DS33 6-axis accelerometer and gyroscope.
1314
1415
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to.
15-
:param address: The I2C address of the sensor
16+
:param int address: The I2C device address. Defaults to :const:`0x6A`
17+
18+
19+
**Quickstart: Importing and using the device**
20+
21+
Here is an example of using the :class:`LSM6DS33` class.
22+
First you will need to import the libraries to use the sensor
23+
24+
.. code-block:: python
25+
26+
import board
27+
from adafruit_lsm6ds.lsm6ds33 import LSM6DS33
28+
29+
Once this is done you can define your `board.I2C` object and define your sensor object
30+
31+
.. code-block:: python
32+
33+
i2c = board.I2C() # uses board.SCL and board.SDA
34+
sensor = LSM6DS33(i2c)
35+
36+
Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes
37+
38+
.. code-block:: python
39+
40+
acc_x, acc_y, acc_z = sensor.acceleration
41+
gyro_x, gyro_z, gyro_z = sensor.gyro
42+
1643
"""
1744

1845
CHIP_ID = 0x69

adafruit_lsm6ds/lsm6dso32.py

+30-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44
"""
5-
This module provides the LSM6DSO32 subclass of LSM6DS for using LSM6DSO32 sensors.
5+
This module provides the `adafruit_lsm6ds.lsm6dso32` subclass of LSM6DS sensors
6+
=================================================================================
67
"""
78
from . import LSM6DS, LSM6DS_CHIP_ID, LSM6DS_DEFAULT_ADDRESS, AccelRange
89

@@ -12,7 +13,34 @@ class LSM6DSO32(LSM6DS): # pylint: disable=too-many-instance-attributes
1213
"""Driver for the LSM6DSO32 6-axis accelerometer and gyroscope.
1314
1415
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSO32 is connected to.
15-
:param address: The I2C address of the sensor
16+
:param address: The I2C device address. Defaults to :const:`0x6A`
17+
18+
19+
**Quickstart: Importing and using the device**
20+
21+
Here is an example of using the :class:`LSM6DSO32` class.
22+
First you will need to import the libraries to use the sensor
23+
24+
.. code-block:: python
25+
26+
import board
27+
from adafruit_lsm6ds.lsm6dso32 import LSM6DSO32
28+
29+
Once this is done you can define your `board.I2C` object and define your sensor object
30+
31+
.. code-block:: python
32+
33+
i2c = board.I2C() # uses board.SCL and board.SDA
34+
sensor = LSM6DSO32(i2c)
35+
36+
Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes
37+
38+
.. code-block:: python
39+
40+
acc_x, acc_y, acc_z = sensor.acceleration
41+
gyro_x, gyro_z, gyro_z = sensor.gyro
42+
43+
1644
"""
1745

1846
CHIP_ID = LSM6DS_CHIP_ID

adafruit_lsm6ds/lsm6dsox.py

+29-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44
"""
5-
This module provides the LSM6DSOX subclass of LSM6DS for using LSM6DSOX sensors.
5+
This module provides the `adafruit_lsm6ds.lsm6dsox` subclass of LSM6DS sensors
6+
==============================================================================
67
"""
78
from . import LSM6DS, LSM6DS_DEFAULT_ADDRESS, LSM6DS_CHIP_ID
89

@@ -12,7 +13,33 @@ class LSM6DSOX(LSM6DS): # pylint: disable=too-many-instance-attributes
1213
"""Driver for the LSM6DSOX 6-axis accelerometer and gyroscope.
1314
1415
:param ~busio.I2C i2c_bus: The I2C bus the LSM6DSOX is connected to.
15-
:param address: The I2C address of the sensor
16+
:param int address: The I2C device address. Defaults to :const:`0x6A`
17+
18+
19+
**Quickstart: Importing and using the device**
20+
21+
Here is an example of using the :class:`LSM6DSOX` class.
22+
First you will need to import the libraries to use the sensor
23+
24+
.. code-block:: python
25+
26+
import board
27+
from adafruit_lsm6ds.lsm6dsox import LSM6DSOX
28+
29+
Once this is done you can define your `board.I2C` object and define your sensor object
30+
31+
.. code-block:: python
32+
33+
i2c = board.I2C() # uses board.SCL and board.SDA
34+
sensor = LSM6DSOX(i2c)
35+
36+
Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes
37+
38+
.. code-block:: python
39+
40+
acc_x, acc_y, acc_z = sensor.acceleration
41+
gyro_x, gyro_z, gyro_z = sensor.gyro
42+
1643
"""
1744

1845
CHIP_ID = LSM6DS_CHIP_ID

docs/api.rst

+15
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,18 @@
66
77
.. automodule:: adafruit_lsm6ds
88
:members:
9+
:exclude-members: CV, AccelRange, GyroRange, AccelHPF, Rate
10+
:member-order: bysource
11+
12+
13+
.. automodule:: adafruit_lsm6ds.ism330dhcx
14+
:members:
15+
16+
.. automodule:: adafruit_lsm6ds.lsm6ds33
17+
:members:
18+
19+
.. automodule:: adafruit_lsm6ds.lsm6dso32
20+
:members:
21+
22+
.. automodule:: adafruit_lsm6ds.lsm6dsox
23+
:members:

0 commit comments

Comments
 (0)