Skip to content

improving_docs #12

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_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