diff --git a/README.rst b/README.rst index 0b26ebf..cdd1fb5 100644 --- a/README.rst +++ b/README.rst @@ -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: diff --git a/adafruit_tlv493d.py b/adafruit_tlv493d.py index b571b72..b5809c2 100644 --- a/adafruit_tlv493d.py +++ b/adafruit_tlv493d.py @@ -15,16 +15,17 @@ **Hardware:** - -Adafruit's TLV493D Breakout https://adafruit.com/products +* Adafruit `TLV493D Triple-Axis Magnetometer + `_ **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 @@ -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 """ diff --git a/docs/index.rst b/docs/index.rst index e2eb109..977899f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,10 +23,12 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit TLV493D Triple-Axis Magnetometer Learning Guide + .. toctree:: :caption: Related Products - Adafruit TLV493D Breakout + Adafruit TLV493D Triple-Axis Magnetometer .. toctree:: :caption: Other Links diff --git a/examples/tlv493d_simpletest.py b/examples/tlv493d_simpletest.py index 9d8da0d..b505748 100644 --- a/examples/tlv493d_simpletest.py +++ b/examples/tlv493d_simpletest.py @@ -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: