Skip to content

Commit

Permalink
Merge pull request #13 from jposada202020/improving_docs
Browse files Browse the repository at this point in the history
improving_docs
  • Loading branch information
kattni authored Apr 27, 2021
2 parents 92f1c85 + a6581a9 commit ddcd47c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ 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_lsm303dlh_mag
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
while True:
Expand Down
26 changes: 25 additions & 1 deletion adafruit_lsm303dlh_mag.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,31 @@
class LSM303DLH_Mag:
"""Driver for the Driver for the LSM303DLH's 'magnetometer.
:param busio.I2C i2c_bus: The I2C bus the LSM303DLH is connected to.
:param ~busio.I2C i2c: The I2C bus the device is connected to.
**Quickstart: Importing and using the device**
Here is an example of using the :class:`LSM303DLH_Mag` class.
First you will need to import the libraries to use the sensor
.. code-block:: python
import board
import adafruit_lsm303dlh_mag
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
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
Now you have access to the :attr:`magnetic` attribute
.. code-block:: python
mag_x, mag_y, mag_z = sensor.magnetic
"""

Expand Down
14 changes: 14 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ Ensure your device works with these simple tests.
:caption: examples/lsm303dlh_mag_simpletest.py
:linenos:

Fast Data Reading Example
-------------------------

Fast readings example

.. literalinclude:: ../examples/lsm303dlh_mag_fast.py
:caption: examples/lsm303dlh_mag_fast.py
:linenos:

Compass Example
---------------

Magnetic compass example

.. literalinclude:: ../examples/lsm303dlh_mag_compass.py
:caption: examples/lsm303dlh_mag_compass.py
:linenos:
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit LIS3DH Triple-Axis Accelerometer Breakout Learning Guide <https://learn.adafruit.com/adafruit-circuit-playground-express>

Circuit Playground Express Learning Guide <https://learn.adafruit.com/adafruit-circuit-playground-express>


.. toctree::
:caption: Related Products

Expand Down
3 changes: 1 addition & 2 deletions examples/lsm303dlh_mag_compass.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import time
from math import atan2, degrees
import board
import busio
import adafruit_lsm303dlh_mag

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)


Expand Down
3 changes: 1 addition & 2 deletions examples/lsm303dlh_mag_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
""" Read data from the magnetometer and print it out, ASAP! """

import board
import busio
import adafruit_lsm303dlh_mag

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)

while True:
Expand Down
3 changes: 1 addition & 2 deletions examples/lsm303dlh_mag_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

import time
import board
import busio
import adafruit_lsm303dlh_mag

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)

while True:
Expand Down

0 comments on commit ddcd47c

Please sign in to comment.