Skip to content

Commit a6581a9

Browse files
committed
improving_docs
1 parent 92f1c85 commit a6581a9

File tree

7 files changed

+49
-10
lines changed

7 files changed

+49
-10
lines changed

README.rst

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

58-
.. code-block:: python
58+
.. code-block:: python3
5959
6060
import time
6161
import board
62-
import busio
6362
import adafruit_lsm303dlh_mag
6463
65-
i2c = busio.I2C(board.SCL, board.SDA)
64+
i2c = board.I2C() # uses board.SCL and board.SDA
6665
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
6766
6867
while True:

adafruit_lsm303dlh_mag.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,31 @@
8989
class LSM303DLH_Mag:
9090
"""Driver for the Driver for the LSM303DLH's 'magnetometer.
9191
92-
:param busio.I2C i2c_bus: The I2C bus the LSM303DLH is connected to.
92+
:param ~busio.I2C i2c: The I2C bus the device is connected to.
93+
94+
95+
**Quickstart: Importing and using the device**
96+
97+
Here is an example of using the :class:`LSM303DLH_Mag` class.
98+
First you will need to import the libraries to use the sensor
99+
100+
.. code-block:: python
101+
102+
import board
103+
import adafruit_lsm303dlh_mag
104+
105+
Once this is done you can define your `board.I2C` object and define your sensor object
106+
107+
.. code-block:: python
108+
109+
i2c = board.I2C() # uses board.SCL and board.SDA
110+
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
111+
112+
Now you have access to the :attr:`magnetic` attribute
113+
114+
.. code-block:: python
115+
116+
mag_x, mag_y, mag_z = sensor.magnetic
93117
94118
"""
95119

docs/examples.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ Ensure your device works with these simple tests.
77
:caption: examples/lsm303dlh_mag_simpletest.py
88
:linenos:
99

10+
Fast Data Reading Example
11+
-------------------------
12+
13+
Fast readings example
14+
1015
.. literalinclude:: ../examples/lsm303dlh_mag_fast.py
1116
:caption: examples/lsm303dlh_mag_fast.py
1217
:linenos:
18+
19+
Compass Example
20+
---------------
21+
22+
Magnetic compass example
23+
24+
.. literalinclude:: ../examples/lsm303dlh_mag_compass.py
25+
:caption: examples/lsm303dlh_mag_compass.py
26+
:linenos:

docs/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit LIS3DH Triple-Axis Accelerometer Breakout Learning Guide <https://learn.adafruit.com/adafruit-circuit-playground-express>
27+
28+
Circuit Playground Express Learning Guide <https://learn.adafruit.com/adafruit-circuit-playground-express>
29+
30+
2631
.. toctree::
2732
:caption: Related Products
2833

examples/lsm303dlh_mag_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_lsm303dlh_mag
109

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

1413

examples/lsm303dlh_mag_fast.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
""" Read data from the magnetometer and print it out, ASAP! """
55

66
import board
7-
import busio
87
import adafruit_lsm303dlh_mag
98

10-
i2c = busio.I2C(board.SCL, board.SDA)
9+
i2c = board.I2C() # uses board.SCL and board.SDA
1110
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
1211

1312
while True:

examples/lsm303dlh_mag_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_lsm303dlh_mag
109

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

1413
while True:

0 commit comments

Comments
 (0)