Skip to content

Commit

Permalink
Merge pull request #12 from jposada202020/improving_docs
Browse files Browse the repository at this point in the history
improving_docs
  • Loading branch information
kattni committed Apr 27, 2021
2 parents 588dc15 + 9080e7d commit 4194599
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 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_tlv493d
i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
tlv = adafruit_tlv493d.TLV493D(i2c)
while True:
Expand Down
37 changes: 31 additions & 6 deletions adafruit_tlv493d.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
**Hardware:**
Adafruit's TLV493D Breakout https://adafruit.com/products
* Adafruit `TLV493D Triple-Axis Magnetometer
<https://www.adafruit.com/product/4366>`_
**Software and Dependencies:**
* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
https://circuitpython.org/downloads
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""

import struct
Expand All @@ -40,9 +41,33 @@
class TLV493D:
"""Driver for the TLV493D 3-axis Magnetometer.
:param busio.I2C i2c_bus: The I2C bus the TLV493D is connected to.
:param int address: The I2C address of the TLV493D. Defaults to 0x5E.
:param int addr_reg: Initial value of the I2C address register. Defaults to 0.
:param ~busio.I2C i2c_bus: The I2C bus the device is connected to
:param int address: The I2C device address. Defaults to :const:`0x5E`
:param int addr_reg: Initial value of the I2C address register. Defaults to :const:`0`.
**Quickstart: Importing and using the device**
Here is an example of using the :class:`TLV493D` class.
First you will need to import the libraries to use the sensor
.. code-block:: python
import board
import adafruit_tlv493d
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
tlv = adafruit_tlv493d.TLV493D(i2c)
Now you have access to the :attr:`magnetic` attribute
.. code-block:: python
acc_x, acc_y, acc_z = tlv.magnetic
"""

Expand Down
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit TLV493D Triple-Axis Magnetometer Learning Guide <https://learn.adafruit.com/adafruit-tlv493-triple-axis-magnetometer>

.. toctree::
:caption: Related Products

Adafruit TLV493D Breakout <https://adafruit.com/products>
Adafruit TLV493D Triple-Axis Magnetometer <https://www.adafruit.com/product/4366>

.. toctree::
:caption: Other Links
Expand Down
3 changes: 1 addition & 2 deletions examples/tlv493d_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

import time
import board
import busio
import adafruit_tlv493d

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
tlv = adafruit_tlv493d.TLV493D(i2c)

while True:
Expand Down

0 comments on commit 4194599

Please sign in to comment.