Skip to content

Commit 877b261

Browse files
authored
Merge pull request #28 from jposada202020/improving_docs
improving_docs
2 parents b187198 + 54573b8 commit 877b261

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

README.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ Usage Example
5757
.. code-block:: python3
5858
5959
import time
60-
import busio
6160
import board
62-
6361
import adafruit_mlx90393
6462
65-
I2C_BUS = busio.I2C(board.SCL, board.SDA)
66-
SENSOR = adafruit_mlx90393.MLX90393(I2C_BUS, gain=adafruit_mlx90393.GAIN_1X)
63+
i2c = board.I2C() # uses board.SCL and board.SDA
64+
SENSOR = adafruit_mlx90393.MLX90393(i2c, gain=adafruit_mlx90393.GAIN_1X)
6765
6866
while True:
6967
MX, MY, MZ = SENSOR.magnetic

adafruit_mlx90393.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
**Software and Dependencies:**
2222
2323
* Adafruit CircuitPython firmware for the supported boards:
24-
https://github.com/adafruit/circuitpython/releases
25-
24+
https://circuitpython.org/downloads
2625
* Adafruit's Bus Device library:
2726
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27+
* Adafruit's Register library:
28+
https://github.com/adafruit/Adafruit_CircuitPython_Register
2829
2930
"""
3031

@@ -162,11 +163,36 @@
162163
class MLX90393: # pylint: disable=too-many-instance-attributes
163164
"""
164165
Driver for the MLX90393 magnetometer.
165-
:param i2c_bus: The `busio.I2C` object to use. This is the only
166-
required parameter.
167-
:param int address: (optional) The I2C address of the device.
168-
:param int gain: (optional) The gain level to apply.
169-
:param bool debug: (optional) Enable debug output.
166+
167+
:param i2c_bus: The I2C bus the device is connected to
168+
:param int address: The I2C device address. Defaults to :const:`0x0C`
169+
:param int gain: The gain level to apply. Defaults to :const:`GAIN_1X`
170+
:param bool debug: Enable debug output. Defaults to `False`
171+
172+
173+
**Quickstart: Importing and using the device**
174+
175+
Here is an example of using the :class:`MLX90393` class.
176+
First you will need to import the libraries to use the sensor
177+
178+
.. code-block:: python
179+
180+
import board
181+
import adafruit_mlx90393
182+
183+
Once this is done you can define your `board.I2C` object and define your sensor object
184+
185+
.. code-block:: python
186+
187+
i2c = board.I2C() # uses board.SCL and board.SDA
188+
SENSOR = adafruit_mlx90393.MLX90393(i2c)
189+
190+
Now you have access to the :attr:`magnetic` attribute
191+
192+
.. code-block:: python
193+
194+
MX, MY, MZ = SENSOR.magnetic
195+
170196
"""
171197

172198
def __init__(
@@ -208,8 +234,10 @@ def _transceive(self, payload, rxlen=0):
208234
"""
209235
Writes the specified 'payload' to the sensor
210236
Returns the results of the write attempt.
211-
:param bytearray payload: The byte array to write to the sensor
212-
:param rxlen: (optional) The numbers of bytes to read back (default=0)
237+
238+
:param bytes payload: The byte array to write to the sensor
239+
:param int rxlen: numbers of bytes to read back. Defaults to :const:`0`
240+
213241
"""
214242
# Read the response (+1 to account for the mandatory status byte!)
215243
data = bytearray(rxlen + 1)
@@ -351,7 +379,7 @@ def oversampling(self, level):
351379

352380
def display_status(self):
353381
"""
354-
Prints out the content of the last status byte in a human-readble
382+
Prints out the content of the last status byte in a human-readable
355383
format.
356384
"""
357385
avail = 0

docs/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit Wide-Range Triple-axis Magnetometer - MLX90393 Learning Guide <https://learn.adafruit.com/mlx90393-wide-range-3-axis-magnetometer>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

31+
Adafruit Wide-Range Triple-axis Magnetometer - MLX90393 <https://www.adafruit.com/product/4022>
32+
2933
.. toctree::
3034
:caption: Other Links
3135

examples/mlx90393_simpletest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
# SPDX-License-Identifier: MIT
33

44
import time
5-
import busio
65
import board
7-
86
import adafruit_mlx90393
97

10-
I2C_BUS = busio.I2C(board.SCL, board.SDA)
11-
SENSOR = adafruit_mlx90393.MLX90393(I2C_BUS, gain=adafruit_mlx90393.GAIN_1X)
8+
i2c = board.I2C() # uses board.SCL and board.SDA
9+
SENSOR = adafruit_mlx90393.MLX90393(i2c, gain=adafruit_mlx90393.GAIN_1X)
1210

1311
while True:
1412
MX, MY, MZ = SENSOR.magnetic

0 commit comments

Comments
 (0)