Skip to content

improving_docs #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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