Skip to content

Commit ea385ad

Browse files
Merge pull request #22 from jposada202020/improving_docs
improving_docs
2 parents 6fdb13f + fe64873 commit ea385ad

File tree

4 files changed

+86
-29
lines changed

4 files changed

+86
-29
lines changed

README.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,30 @@ Usage Example
5656

5757
Of course, you must import the library to use it:
5858

59-
.. code:: python
59+
.. code:: python3
6060
6161
import adafruit_l3gd20
6262
6363
64-
This driver takes an instantiated and active I2C object (from the `busio` or
65-
the `bitbangio` library) as an argument to its constructor. The way to create
66-
an I2C object depends on the board you are using. For boards with labeled SCL
67-
and SDA pins, you can:
64+
This driver takes an instantiated and active I2C object as an argument
65+
to its constructor.
6866

69-
.. code:: python
67+
.. code:: python3
7068
71-
from busio import I2C
72-
from board import SDA, SCL
69+
import board
7370
74-
i2c = I2C(SCL, SDA)
71+
i2c = board.I2C()
7572
7673
Once you have the I2C object, you can create the sensor object:
7774

78-
.. code:: python
75+
.. code:: python3
7976
8077
sensor = adafruit_l3gd20.L3GD20_I2C(i2c)
8178
8279
8380
And then you can start reading the measurements:
8481

85-
.. code:: python
82+
.. code:: python3
8683
8784
print(sensor.gyro)
8885

adafruit_l3gd20.py

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
1919
**Hardware:**
2020
21-
* `L3GD20H Triple-Axis Gyro Breakout Board <https://www.adafruit.com/product/1032>`_
21+
* Adafruit `L3GD20H Triple-Axis Gyro Breakout Board <https://www.adafruit.com/product/1032>`_
2222
2323
**Software and Dependencies:**
2424
2525
* Adafruit CircuitPython firmware for the supported boards:
26-
https://github.com/adafruit/circuitpython/releases
26+
https://circuitpython.org/downloads
2727
2828
2929
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
@@ -77,11 +77,22 @@ class L3GD20:
7777
"""
7878
Driver for the L3GD20 3-axis Gyroscope sensor.
7979
80-
:param int rng: a range value one of L3DS20_RANGE_250DPS (default), L3DS20_RANGE_500DPS, or
81-
L3DS20_RANGE_2000DPS
80+
:param int rng: a range value one of:
8281
83-
:param int rate: a rate value one of L3DS20_RATE_100HZ (default), L3DS20_RATE_200HZ,
84-
L3DS20_RATE_400HZ, or L3DS20_RATE_800HZ
82+
* :const:`L3DS20_RANGE_250DPS`
83+
* :const:`L3DS20_RANGE_500DPS`
84+
* :const:`L3DS20_RANGE_2000DPS`
85+
86+
Defaults to :const:`L3DS20_RANGE_250DPS`
87+
88+
:param int rate: a rate value one of
89+
90+
* :const:`L3DS20_RATE_100HZ`
91+
* :const:`L3DS20_RATE_200HZ`
92+
* :const:`L3DS20_RATE_400HZ`
93+
* :const:`L3DS20_RATE_800HZ`
94+
95+
Defaults to :const:`L3DS20_RATE_100HZ`
8596
"""
8697

8798
def __init__(self, rng=L3DS20_RANGE_250DPS, rate=L3DS20_RATE_100HZ):
@@ -194,10 +205,35 @@ class L3GD20_I2C(L3GD20):
194205
"""
195206
Driver for L3GD20 Gyroscope using I2C communications
196207
197-
:param ~busio.I2C i2c: initialized busio I2C class
198-
:param int rng: the optional range value: L3DS20_RANGE_250DPS(default), L3DS20_RANGE_500DPS, or
199-
L3DS20_RANGE_2000DPS
200-
:param address: the optional device address, 0x68 is the default address
208+
:param ~busio.I2C i2c: The I2C bus the device is connected to
209+
:param int rng: range value. Defaults to :const:`0x68`
210+
:param int rate: rate value. Defaults to :const:`L3DS20_RATE_100HZ`
211+
212+
213+
**Quickstart: Importing and using the device**
214+
215+
Here is an example of using the :class:`L3GD20_I2C` class.
216+
First you will need to import the libraries to use the sensor
217+
218+
.. code-block:: python
219+
220+
import board
221+
import adafruit_l3gd20
222+
223+
Once this is done you can define your `board.I2C` object and define your sensor object
224+
225+
.. code-block:: python
226+
227+
i2c = board.I2C() # uses board.SCL and board.SDA
228+
sensor = adafruit_l3gd20.L3GD20_I2C(i2c)
229+
230+
Now you have access to the :attr:`gyro` attribute
231+
232+
.. code-block:: python
233+
234+
gyro_data = sensor.gyro
235+
236+
201237
"""
202238

203239
gyro_raw = Struct(_L3GD20_REGISTER_OUT_X_L_X80, "<hhh")
@@ -240,11 +276,36 @@ class L3GD20_SPI(L3GD20):
240276
"""
241277
Driver for L3GD20 Gyroscope using SPI communications
242278
243-
:param ~busio.SPI spi_busio: initialized busio SPI class
279+
:param ~busio.SPI spi_busio: The SPI bus the device is connected to
244280
:param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal
245-
:param int rng: the optional range value: L3DS20_RANGE_250DPS(default), L3DS20_RANGE_500DPS, or
246-
L3DS20_RANGE_2000DPS
247-
:param baudrate: spi baud rate default is 100000
281+
:param int rng: range value. Defaults to :const:`L3DS20_RANGE_250DPS`.
282+
:param baudrate: SPI baud rate. Defaults to :const:`100000`
283+
:param int rate: rate value. Defaults to :const:`L3DS20_RATE_100HZ`
284+
285+
**Quickstart: Importing and using the device**
286+
287+
Here is an example of using the :class:`L3GD20_SPI` class.
288+
First you will need to import the libraries to use the sensor
289+
290+
.. code-block:: python
291+
292+
import board
293+
import adafruit_l3gd20
294+
295+
Once this is done you can define your `board.SPI` object and define your sensor object
296+
297+
.. code-block:: python
298+
299+
spi = board.SPI()
300+
sensor = adafruit_l3gd20.L3GD20_SPI(spi)
301+
302+
Now you have access to the :attr:`gyro` attribute
303+
304+
.. code-block:: python
305+
306+
gyro_data = sensor.gyro
307+
308+
248309
"""
249310

250311
def __init__(

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
Adafruit Triple Axis Gyro Breakout <https://learn.adafruit.com/adafruit-triple-axis-gyro-breakout>
26+
Adafruit Triple Axis Gyro Breakout Learning Guide <https://learn.adafruit.com/adafruit-triple-axis-gyro-breakout>
2727

2828
.. toctree::
2929
:caption: Related Products

examples/l3gd20_simpletest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
import time
55
import board
6-
import busio
76
import adafruit_l3gd20
87

98
# Hardware I2C setup:
10-
I2C = busio.I2C(board.SCL, board.SDA)
9+
I2C = board.I2C() # uses board.SCL and board.SDA
1110
# Initializes L3GD20 object using default range, 250dps
1211
SENSOR = adafruit_l3gd20.L3GD20_I2C(I2C)
1312
# Initialize L3GD20 object using a custom range and output data rate (ODR).
@@ -29,7 +28,7 @@
2928
# Hardware SPI setup:
3029
# import digitalio
3130
# CS = digitalio.DigitalInOut(board.D5)
32-
# SPIB = busio.SPI(board.SCK, board.MOSI, board.MISO)
31+
# SPIB = board.SPI()
3332
# SENSOR = adafruit_l3gd20.L3GD20_SPI(SPIB, CS)
3433
# SENSOR = adafruit_l3gd20.L3GD20_I2C(
3534
# SPIB,

0 commit comments

Comments
 (0)