File tree Expand file tree Collapse file tree 7 files changed +49
-10
lines changed Expand file tree Collapse file tree 7 files changed +49
-10
lines changed Original file line number Diff line number Diff line change @@ -55,14 +55,13 @@ To install in a virtual environment in your current project:
5555 Usage Example
5656=============
5757
58- .. code-block :: python
58+ .. code-block :: python3
5959
6060 import time
6161 import board
62- import busio
6362 import adafruit_lsm303dlh_mag
6463
65- i2c = busio .I2C(board.SCL , board.SDA )
64+ i2c = board .I2C() # uses board.SCL and board.SDA
6665 sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
6766
6867 while True:
Original file line number Diff line number Diff line change 8989class LSM303DLH_Mag :
9090 """Driver for the Driver for the LSM303DLH's 'magnetometer.
9191
92- :param busio.I2C i2c_bus: The I2C bus the LSM303DLH is connected to.
92+ :param ~busio.I2C i2c: The I2C bus the device is connected to.
93+
94+
95+ **Quickstart: Importing and using the device**
96+
97+ Here is an example of using the :class:`LSM303DLH_Mag` class.
98+ First you will need to import the libraries to use the sensor
99+
100+ .. code-block:: python
101+
102+ import board
103+ import adafruit_lsm303dlh_mag
104+
105+ Once this is done you can define your `board.I2C` object and define your sensor object
106+
107+ .. code-block:: python
108+
109+ i2c = board.I2C() # uses board.SCL and board.SDA
110+ sensor = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c)
111+
112+ Now you have access to the :attr:`magnetic` attribute
113+
114+ .. code-block:: python
115+
116+ mag_x, mag_y, mag_z = sensor.magnetic
93117
94118 """
95119
Original file line number Diff line number Diff line change @@ -7,6 +7,20 @@ Ensure your device works with these simple tests.
77 :caption: examples/lsm303dlh_mag_simpletest.py
88 :linenos:
99
10+ Fast Data Reading Example
11+ -------------------------
12+
13+ Fast readings example
14+
1015.. literalinclude :: ../examples/lsm303dlh_mag_fast.py
1116 :caption: examples/lsm303dlh_mag_fast.py
1217 :linenos:
18+
19+ Compass Example
20+ ---------------
21+
22+ Magnetic compass example
23+
24+ .. literalinclude :: ../examples/lsm303dlh_mag_compass.py
25+ :caption: examples/lsm303dlh_mag_compass.py
26+ :linenos:
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ Table of Contents
2323.. toctree ::
2424 :caption: Tutorials
2525
26+ Adafruit LIS3DH Triple-Axis Accelerometer Breakout Learning Guide <https://learn.adafruit.com/adafruit-circuit-playground-express >
27+
28+ Circuit Playground Express Learning Guide <https://learn.adafruit.com/adafruit-circuit-playground-express >
29+
30+
2631.. toctree ::
2732 :caption: Related Products
2833
Original file line number Diff line number Diff line change 55import time
66from math import atan2 , degrees
77import board
8- import busio
98import adafruit_lsm303dlh_mag
109
11- i2c = busio .I2C (board .SCL , board .SDA )
10+ i2c = board .I2C () # uses board.SCL and board.SDA
1211sensor = adafruit_lsm303dlh_mag .LSM303DLH_Mag (i2c )
1312
1413
Original file line number Diff line number Diff line change 44""" Read data from the magnetometer and print it out, ASAP! """
55
66import board
7- import busio
87import adafruit_lsm303dlh_mag
98
10- i2c = busio .I2C (board .SCL , board .SDA )
9+ i2c = board .I2C () # uses board.SCL and board.SDA
1110sensor = adafruit_lsm303dlh_mag .LSM303DLH_Mag (i2c )
1211
1312while True :
Original file line number Diff line number Diff line change 55
66import time
77import board
8- import busio
98import adafruit_lsm303dlh_mag
109
11- i2c = busio .I2C (board .SCL , board .SDA )
10+ i2c = board .I2C () # uses board.SCL and board.SDA
1211sensor = adafruit_lsm303dlh_mag .LSM303DLH_Mag (i2c )
1312
1413while True :
You can’t perform that action at this time.
0 commit comments