24
24
25
25
**Software and Dependencies:**
26
26
27
- * Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
28
- https://github.com/adafruit/circuitpython/releases
29
- * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27
+ * Adafruit CircuitPython firmware for the supported boards:
28
+ https://circuitpython.org/downloads
29
+ * Adafruit's Bus Device library:
30
+ https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
30
31
"""
31
32
32
33
__version__ = "0.0.0-auto.0"
@@ -166,10 +167,12 @@ def __init__(self):
166
167
@property
167
168
def accel_range (self ):
168
169
"""The accelerometer range. Must be a value of:
170
+
169
171
- ACCELRANGE_2G
170
172
- ACCELRANGE_4G
171
173
- ACCELRANGE_8G
172
174
- ACCELRANGE_16G
175
+
173
176
"""
174
177
reg = self ._read_u8 (_XGTYPE , _LSM9DS1_REGISTER_CTRL_REG6_XL )
175
178
return (reg & 0b00011000 ) & 0xFF
@@ -193,10 +196,12 @@ def accel_range(self, val):
193
196
@property
194
197
def mag_gain (self ):
195
198
"""The magnetometer gain. Must be a value of:
199
+
196
200
- MAGGAIN_4GAUSS
197
201
- MAGGAIN_8GAUSS
198
202
- MAGGAIN_12GAUSS
199
203
- MAGGAIN_16GAUSS
204
+
200
205
"""
201
206
reg = self ._read_u8 (_MAGTYPE , _LSM9DS1_REGISTER_CTRL_REG2_M )
202
207
return (reg & 0b01100000 ) & 0xFF
@@ -220,9 +225,11 @@ def mag_gain(self, val):
220
225
@property
221
226
def gyro_scale (self ):
222
227
"""The gyroscope scale. Must be a value of:
223
- - GYROSCALE_245DPS
224
- - GYROSCALE_500DPS
225
- - GYROSCALE_2000DPS
228
+
229
+ * GYROSCALE_245DPS
230
+ * GYROSCALE_500DPS
231
+ * GYROSCALE_2000DPS
232
+
226
233
"""
227
234
reg = self ._read_u8 (_XGTYPE , _LSM9DS1_REGISTER_CTRL_REG1_G )
228
235
return (reg & 0b00011000 ) & 0xFF
@@ -255,7 +262,7 @@ def read_accel_raw(self):
255
262
@property
256
263
def acceleration (self ):
257
264
"""The accelerometer X, Y, Z axis values as a 3-tuple of
258
- m/s^2 values.
265
+ :math:` m/s^2` values.
259
266
"""
260
267
raw = self .read_accel_raw ()
261
268
return map (
@@ -345,18 +352,44 @@ def _write_u8(self, sensor_type, address, val):
345
352
class LSM9DS1_I2C (LSM9DS1 ):
346
353
"""Driver for the LSM9DS1 connect over I2C.
347
354
348
- :param ~busio.I2C i2c: The I2C bus object used to connect to the LSM9DS1.
349
-
350
- .. note:: This object should be shared among other driver classes that use the
351
- same I2C bus (SDA & SCL pins) to connect to different I2C devices.
355
+ :param ~busio.I2C i2c: The I2C bus the device is connected to
352
356
353
357
:param int mag_address: A 8-bit integer that represents the i2c address of the
354
- LSM9DS1's magnetometer. Options are limited to `` 0x1C`` or `` 0x1E``.
355
- Defaults to `` 0x1E` `.
358
+ LSM9DS1's magnetometer. Options are limited to :const:` 0x1C` or :const:` 0x1E`
359
+ Defaults to :const:` 0x1E`.
356
360
357
361
:param int xg_address: A 8-bit integer that represents the i2c address of the
358
- LSM9DS1's accelerometer and gyroscope. Options are limited to ``0x6A`` or ``0x6B``.
359
- Defaults to ``0x6B``.
362
+ LSM9DS1's accelerometer and gyroscope. Options are limited to :const:`0x6A`
363
+ or :const:`0x6B`. Defaults to :const:`0x6B`.
364
+
365
+
366
+ **Quickstart: Importing and using the device**
367
+
368
+ Here is an example of using the :class:`LSM9DS1` class.
369
+ First you will need to import the libraries to use the sensor
370
+
371
+ .. code-block:: python
372
+
373
+ import board
374
+ import adafruit_lsm9ds1
375
+
376
+ Once this is done you can define your `board.I2C` object and define your sensor object
377
+
378
+ .. code-block:: python
379
+
380
+ i2c = board.I2C() # uses board.SCL and board.SDA
381
+ sensor = adafruit_lsm9ds1.LSM9DS1_I2C(i2c)
382
+
383
+ Now you have access to the :attr:`acceleration`, :attr:`magnetic`
384
+ :attr:`gyro` and :attr:`temperature` attributes
385
+
386
+ .. code-block:: python
387
+
388
+ acc_x, acc_y, acc_z = sensor.acceleration
389
+ mag_x, mag_y, mag_z = sensor.magnetic
390
+ gyro_x, gyro_y, gyro_z = sensor.gyro
391
+ temp = sensor.temperature
392
+
360
393
361
394
"""
362
395
@@ -412,17 +445,42 @@ def _write_u8(self, sensor_type, address, val):
412
445
class LSM9DS1_SPI (LSM9DS1 ):
413
446
"""Driver for the LSM9DS1 connect over SPI.
414
447
415
- :param ~busio.SPI spi: The SPI bus object used to connect to the LSM9DS1.
416
-
417
- .. note:: This object should be shared among other driver classes that use the
418
- same SPI bus (SCK, MISO, MOSI pins) to connect to different SPI devices.
448
+ :param ~busio.SPI spi: The SPI bus the device is connected to
419
449
420
450
:param ~digitalio.DigitalInOut mcs: The digital output pin connected to the
421
451
LSM9DS1's CSM (Chip Select Magnetometer) pin.
422
452
423
453
:param ~digitalio.DigitalInOut xgcs: The digital output pin connected to the
424
454
LSM9DS1's CSAG (Chip Select Accelerometer/Gyroscope) pin.
425
455
456
+
457
+ **Quickstart: Importing and using the device**
458
+
459
+ Here is an example of using the :class:`LSM9DS1` class.
460
+ First you will need to import the libraries to use the sensor
461
+
462
+ .. code-block:: python
463
+
464
+ import board
465
+ import adafruit_lsm9ds1
466
+
467
+ Once this is done you can define your `board.SPI` object and define your sensor object
468
+
469
+ .. code-block:: python
470
+
471
+ spi = board.SPI()
472
+ sensor = adafruit_lsm9ds1.LSM9DS1_SPI(spi)
473
+
474
+ Now you have access to the :attr:`acceleration`, :attr:`magnetic`
475
+ :attr:`gyro` and :attr:`temperature` attributes
476
+
477
+ .. code-block:: python
478
+
479
+ acc_x, acc_y, acc_z = sensor.acceleration
480
+ mag_x, mag_y, mag_z = sensor.magnetic
481
+ gyro_x, gyro_y, gyro_z = sensor.gyro
482
+ temp = sensor.temperature
483
+
426
484
"""
427
485
428
486
# pylint: disable=no-member
0 commit comments