Skip to content

Commit f441875

Browse files
Merge pull request #16 from jposada202020/master
improving_docs
2 parents d774f38 + 02579e4 commit f441875

9 files changed

+69
-16
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ To install in a virtual environment in your current project:
5656
Usage Example
5757
=============
5858

59-
.. code-block:: python
59+
.. code-block:: python3
6060
6161
import time
6262
import board
63-
import busio
6463
import adafruit_lis3mdl
6564
66-
i2c = busio.I2C(board.SCL, board.SDA)
65+
i2c = board.I2C() # uses board.SCL and board.SDA
6766
sensor = adafruit_lis3mdl.LIS3MDL(i2c)
6867
6968
while True:

adafruit_lis3mdl.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
**Software and Dependencies:**
2121
2222
* Adafruit CircuitPython firmware for the supported boards:
23-
https://github.com/adafruit/circuitpython/releases
23+
https://circuitpython.org/downloads
2424
2525
2626
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
@@ -188,8 +188,34 @@ class OperationMode(CV):
188188

189189
class LIS3MDL:
190190
"""Driver for the LIS3MDL 3-axis magnetometer.
191+
191192
:param ~busio.I2C i2c_bus: The I2C bus the LIS3MDL is connected to.
192-
:param address: The I2C slave address of the sensor
193+
:param address: The I2C device address. Defaults to :const:`0x1C`
194+
195+
**Quickstart: Importing and using the device**
196+
197+
Here is an example of using the :class:`LIS3MDL` class.
198+
First you will need to import the libraries to use the sensor
199+
200+
.. code-block:: python
201+
202+
import board
203+
import adafruit_lis3mdl
204+
205+
Once this is done you can define your `board.I2C` object and define your sensor object
206+
207+
.. code-block:: python
208+
209+
i2c = board.I2C()
210+
sensor = adafruit_lis3mdl.LIS3MDL(i2c)
211+
212+
Now you have access to the :attr:`magnetic` attribute
213+
214+
.. code-block:: python
215+
216+
mag_x, mag_y, mag_z = sensor.magnetic
217+
218+
193219
"""
194220

195221
_chip_id = ROUnaryStruct(_LIS3MDL_WHOAMI, "<b")
@@ -279,7 +305,7 @@ def data_rate(self, value):
279305

280306
@property
281307
def performance_mode(self):
282-
"""Sets the 'performance mode' of the sensor. Must be a `PerformanceMode`.
308+
"""Sets the 'performance mode' of the sensor. Must be a ``PerformanceMode``.
283309
Note that `performance_mode` affects the available data rate and will be
284310
automatically changed by setting ``data_rate`` to certain values."""
285311

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
77
.. automodule:: adafruit_lis3mdl
88
:members:
9+
:exclude-members: CV, Range, PerformanceMode

docs/examples.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Ensure your device works with this simple test.
77
:caption: examples/lis3mdl_simpletest.py
88
:linenos:
99

10+
1011
Compass Example
1112
---------------
1213

@@ -15,3 +16,32 @@ Use the magnetometer to calculate compass headings.
1516
.. literalinclude:: ../examples/lis3mdl_compass.py
1617
:caption: examples/lis3mdl_compass.py
1718
:linenos:
19+
20+
21+
Data Rate Example
22+
-----------------
23+
24+
Test each data rate
25+
26+
.. literalinclude:: ../examples/lis3mdl_data_rate_test.py
27+
:caption: examples/lis3mdl_data_rate_test.py
28+
:linenos:
29+
30+
31+
LSM6DS Test
32+
---------------
33+
34+
Test the LSM6DS device
35+
36+
.. literalinclude:: ../examples/lis3mdl_lsm6ds_test.py
37+
:caption: examples/lis3mdl_lsm6ds_test.py
38+
:linenos:
39+
40+
Range Test
41+
---------------
42+
43+
Test each range
44+
45+
.. literalinclude:: ../examples/lis3mdl_range_test.py
46+
:caption: examples/lis3mdl_range_test.py
47+
:linenos:

examples/lis3mdl_compass.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import time
66
from math import atan2, degrees
77
import board
8-
import busio
98
import adafruit_lis3mdl
109

11-
i2c = busio.I2C(board.SCL, board.SDA)
10+
i2c = board.I2C() # uses board.SCL and board.SDA
1211
sensor = adafruit_lis3mdl.LIS3MDL(i2c)
1312

1413

examples/lis3mdl_data_rate_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
# pylint: disable=no-member
77
import time
88
import board
9-
import busio
109
from adafruit_lis3mdl import LIS3MDL, Rate, PerformanceMode
1110

12-
i2c = busio.I2C(board.SCL, board.SDA)
11+
i2c = board.I2C() # uses board.SCL and board.SDA
1312
sensor = LIS3MDL(i2c)
1413

1514
current_rate = Rate.RATE_155_HZ

examples/lis3mdl_lsm6ds_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
from adafruit_lis3mdl import LIS3MDL
1717

18-
accel_gyro = LSM6DS(board.I2C())
19-
mag = LIS3MDL(board.I2C())
18+
i2c = board.I2C() # uses board.SCL and board.SDA
19+
accel_gyro = LSM6DS(i2c)
20+
mag = LIS3MDL(i2c)
2021

2122
while True:
2223
acceleration = accel_gyro.acceleration

examples/lis3mdl_range_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
# pylint: disable=no-member
66
import time
77
import board
8-
import busio
98
from adafruit_lis3mdl import LIS3MDL, Range
109

11-
i2c = busio.I2C(board.SCL, board.SDA)
10+
i2c = board.I2C() # uses board.SCL and board.SDA
1211
sensor = LIS3MDL(i2c)
1312

1413
while True:

examples/lis3mdl_simpletest.py

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

66
import time
77
import board
8-
import busio
98
import adafruit_lis3mdl
109

11-
i2c = busio.I2C(board.SCL, board.SDA)
10+
i2c = board.I2C() # uses board.SCL and board.SDA
1211
sensor = adafruit_lis3mdl.LIS3MDL(i2c)
1312

1413
while True:

0 commit comments

Comments
 (0)