Skip to content

Commit 529b66a

Browse files
Merge pull request #22 from jposada202020/improving_docs
improving_docs
2 parents 7b68d87 + 0cde49a commit 529b66a

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

README.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ To install in a virtual environment in your current project:
5353
Usage Example
5454
=============
5555

56-
.. code-block:: python
56+
.. code-block:: python3
5757
5858
import time
5959
import board
60-
import busio
6160
import adafruit_fxas21002c
6261
63-
i2c = busio.I2C(board.SCL, board.SDA)
62+
i2c = board.I2C() # uses board.SCL and board.SDA
6463
sensor = adafruit_fxas21002c.FXAS21002C(i2c)
6564
6665
while True:

adafruit_fxas21002c.py

+34-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
2424
**Software and Dependencies:**
2525
26-
* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
27-
https://github.com/adafruit/circuitpython/releases
26+
* Adafruit CircuitPython firmware for the supported boards:
27+
https://circuitpython.org/downloads
2828
2929
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3030
"""
@@ -72,7 +72,37 @@
7272

7373

7474
class FXAS21002C:
75-
"""Driver for the NXP FXAS21002C gyroscope."""
75+
"""Driver for the NXP FXAS21002C gyroscope.
76+
77+
:param ~busio.I2C i2c: The I2C bus the device is connected to
78+
:param int address: The I2C device address. Defaults to :const:`0x21`
79+
:param int gyro_range: Device range. Defaults to :const:`250`.
80+
81+
82+
**Quickstart: Importing and using the device**
83+
84+
Here is an example of using the :class:`FXAS21002C` class.
85+
First you will need to import the libraries to use the sensor
86+
87+
.. code-block:: python
88+
89+
import board
90+
import adafruit_fxas21002c
91+
92+
Once this is done you can define your `board.I2C` object and define your sensor object
93+
94+
.. code-block:: python
95+
96+
i2c = board.I2C() # uses board.SCL and board.SDA
97+
sensor = adafruit_fxas21002c.FXAS21002C(i2c)
98+
99+
Now you have access to the :attr:`gyroscope` attribute
100+
101+
.. code-block:: python
102+
103+
gyro_x, gyro_y, gyro_z = sensor.gyroscope
104+
105+
"""
76106

77107
# Class-level buffer for reading and writing data with the sensor.
78108
# 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
101131
elif gyro_range == GYRO_RANGE_2000DPS:
102132
ctrl_reg0 = 0x00
103133
# Reset then switch to active mode with 100Hz output
104-
# Putting into standy doesn't work as the chip becomes instantly
134+
# Putting into standby doesn't work as the chip becomes instantly
105135
# unresponsive. Perhaps CircuitPython is too slow to go into standby
106136
# and send reset? Keep these two commented for now:
107137
# self._write_u8(_GYRO_REGISTER_CTRL_REG1, 0x00) # Standby)

docs/index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit Precision NXP 9-DOF Breakout Board - FXOS8700 + FXAS21002 Learning Guide <https://learn.adafruit.com/nxp-precision-9dof-breakout/overview>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

examples/fxas21002c_simpletest.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
# Simple demo of the FXAS21002C gyroscope.
55
# Will print the gyroscope values every second.
66
import time
7-
87
import board
9-
import busio
10-
118
import adafruit_fxas21002c
129

1310

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

0 commit comments

Comments
 (0)