From 0cde49a3634d4373b57e1a12c31fa611a4509ea8 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Mon, 26 Apr 2021 09:35:19 -0400 Subject: [PATCH] improving_docs --- README.rst | 5 ++-- adafruit_fxas21002c.py | 38 +++++++++++++++++++++++++++---- docs/index.rst | 2 ++ examples/fxas21002c_simpletest.py | 7 ++---- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index e96e792..5bf6dbd 100644 --- a/README.rst +++ b/README.rst @@ -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: diff --git a/adafruit_fxas21002c.py b/adafruit_fxas21002c.py index 69641e9..cec4fd7 100644 --- a/adafruit_fxas21002c.py +++ b/adafruit_fxas21002c.py @@ -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 """ @@ -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 @@ -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) diff --git a/docs/index.rst b/docs/index.rst index 95a1309..44b467f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,8 @@ Table of Contents .. toctree:: :caption: Tutorials + Adafruit Precision NXP 9-DOF Breakout Board - FXOS8700 + FXAS21002 Learning Guide + .. toctree:: :caption: Related Products diff --git a/examples/fxas21002c_simpletest.py b/examples/fxas21002c_simpletest.py index 10d0757..12ab8ce 100644 --- a/examples/fxas21002c_simpletest.py +++ b/examples/fxas21002c_simpletest.py @@ -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):