Skip to content

improving_docs #22

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 26, 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 @@ -53,14 +53,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_fxas21002c

i2c = busio.I2C(board.SCL, board.SDA)
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_fxas21002c.FXAS21002C(i2c)

while True:
Expand Down
38 changes: 34 additions & 4 deletions adafruit_fxas21002c.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

**Software and Dependencies:**

* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
https://github.com/adafruit/circuitpython/releases
* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
Expand Down Expand Up @@ -72,7 +72,37 @@


class FXAS21002C:
"""Driver for the NXP FXAS21002C gyroscope."""
"""Driver for the NXP FXAS21002C gyroscope.

:param ~busio.I2C i2c: The I2C bus the device is connected to
:param int address: The I2C device address. Defaults to :const:`0x21`
:param int gyro_range: Device range. Defaults to :const:`250`.


**Quickstart: Importing and using the device**

Here is an example of using the :class:`FXAS21002C` class.
First you will need to import the libraries to use the sensor

.. code-block:: python

import board
import adafruit_fxas21002c

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_fxas21002c.FXAS21002C(i2c)

Now you have access to the :attr:`gyroscope` attribute

.. code-block:: python

gyro_x, gyro_y, gyro_z = sensor.gyroscope

"""

# Class-level buffer for reading and writing data with the sensor.
# This reduces memory allocations but means the code is not re-entrant or
Expand Down Expand Up @@ -101,7 +131,7 @@ def __init__(self, i2c, address=_FXAS21002C_ADDRESS, gyro_range=GYRO_RANGE_250DP
elif gyro_range == GYRO_RANGE_2000DPS:
ctrl_reg0 = 0x00
# Reset then switch to active mode with 100Hz output
# Putting into standy doesn't work as the chip becomes instantly
# Putting into standby doesn't work as the chip becomes instantly
# unresponsive. Perhaps CircuitPython is too slow to go into standby
# and send reset? Keep these two commented for now:
# self._write_u8(_GYRO_REGISTER_CTRL_REG1, 0x00) # Standby)
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit Precision NXP 9-DOF Breakout Board - FXOS8700 + FXAS21002 Learning Guide <https://learn.adafruit.com/nxp-precision-9dof-breakout/overview>

.. toctree::
:caption: Related Products

Expand Down
7 changes: 2 additions & 5 deletions examples/fxas21002c_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
# Simple demo of the FXAS21002C gyroscope.
# Will print the gyroscope values every second.
import time

import board
import busio

import adafruit_fxas21002c


# Initialize I2C bus and device.
i2c = busio.I2C(board.SCL, board.SDA)
# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_fxas21002c.FXAS21002C(i2c)
# Optionally create the sensor with a different gyroscope range (the
# default is 250 DPS, but you can use 500, 1000, or 2000 DPS values):
Expand Down