Skip to content

Commit 1e7f645

Browse files
Merge pull request #23 from jposada202020/improving_docs
improving_docs
2 parents fecfb03 + 4deecee commit 1e7f645

File tree

4 files changed

+42
-13
lines changed

4 files changed

+42
-13
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ To install in a virtual environment in your current project:
5454
Usage Example
5555
=============
5656

57-
.. code-block:: python
57+
.. code-block:: python3
5858
5959
import time
6060
import board
61-
import busio
6261
import adafruit_fxos8700
6362
64-
i2c = busio.I2C(board.SCL, board.SDA)
63+
i2c = board.I2C()
6564
sensor = adafruit_fxos8700.FXOS8700(i2c)
6665
6766
while True:

adafruit_fxos8700.py

Lines changed: 36 additions & 5 deletions
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
"""
@@ -87,7 +87,38 @@ def _twos_comp(val, bits):
8787

8888

8989
class FXOS8700:
90-
"""Driver for the NXP FXOS8700 accelerometer and magnetometer."""
90+
"""Driver for the NXP FXOS8700 accelerometer and magnetometer.
91+
92+
:param ~busio.I2C i2c: The I2C bus the device is connected to
93+
:param int address: The I2C device address. Defaults to :const:`0x1F`
94+
:param int accel_range: Device range. Defaults to :const:`0x00`.
95+
96+
97+
**Quickstart: Importing and using the device**
98+
99+
Here is an example of using the :class:`FXOS8700` class.
100+
First you will need to import the libraries to use the sensor
101+
102+
.. code-block:: python
103+
104+
import board
105+
import adafruit_fxos8700
106+
107+
Once this is done you can define your `board.I2C` object and define your sensor object
108+
109+
.. code-block:: python
110+
111+
i2c = board.I2C() # uses board.SCL and board.SDA
112+
sensor = adafruit_fxos8700.FXOS8700(i2c)
113+
114+
Now you have access to the :attr:`accelerometer` and :attr:`magnetometer` attributes
115+
116+
.. code-block:: python
117+
118+
accel_x, accel_y, accel_z = sensor.accelerometer
119+
mag_x, mag_y, mag_z = sensor.magnetometer
120+
121+
"""
91122

92123
# Class-level buffer for reading and writing data with the sensor.
93124
# This reduces memory allocations but means the code is not re-entrant or
@@ -171,7 +202,7 @@ def read_raw_accel_mag(self):
171202
@property
172203
def accelerometer(self):
173204
"""Read the acceleration from the accelerometer and return its X, Y, Z axis values as a
174-
3-tuple in m/s^2.
205+
3-tuple in :math:`m/s^2`.
175206
"""
176207
accel_raw, _ = self.read_raw_accel_mag()
177208
# Convert accel values to m/s^2
@@ -187,7 +218,7 @@ def accelerometer(self):
187218
@property
188219
def magnetometer(self):
189220
"""
190-
Read the magnetometer values and return its X, Y, Z axis values as a 3-tuple in uTeslas.
221+
Read the magnetometer values and return its X, Y, Z axis values as a 3-tuple in μTeslas.
191222
"""
192223
_, mag_raw = self.read_raw_accel_mag()
193224
# Convert mag values to uTesla

docs/index.rst

Lines changed: 2 additions & 0 deletions
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/fxos8700_simpletest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
# Simple demo of the FXOS8700 accelerometer and magnetometer.
55
# Will print the acceleration and magnetometer values every second.
66
import time
7-
87
import board
9-
import busio
10-
118
import adafruit_fxos8700
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()
1613
sensor = adafruit_fxos8700.FXOS8700(i2c)
1714
# Optionally create the sensor with a different accelerometer range (the
1815
# default is 2G, but you can use 4G or 8G values):

0 commit comments

Comments
 (0)