From 7bb6866e53034940659610439f319c72f726cd43 Mon Sep 17 00:00:00 2001 From: Noel Gaetan Date: Wed, 6 Apr 2022 12:40:49 +0200 Subject: [PATCH 1/6] Create lsm6ds3.py add support to lsm6ds3 IMU (include in board Xiao BLE SENSE) --- adafruit_lsm6ds/lsm6ds3.py | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 adafruit_lsm6ds/lsm6ds3.py diff --git a/adafruit_lsm6ds/lsm6ds3.py b/adafruit_lsm6ds/lsm6ds3.py new file mode 100644 index 0000000..6098d27 --- /dev/null +++ b/adafruit_lsm6ds/lsm6ds3.py @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries +# +# SPDX-License-Identifier: MIT +""" +This module provides the `adafruit_lsm6ds.lsm6ds33` subclass of LSM6DS sensors +=============================================================================== +""" +from . import LSM6DS + + +class LSM6DS3(LSM6DS): # pylint: disable=too-many-instance-attributes + + """Driver for the LSM6DS33 6-axis accelerometer and gyroscope. + + :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to. + :param int address: The I2C device address. Defaults to :const:`0x6A` + + + **Quickstart: Importing and using the device** + + Here is an example of using the :class:`LSM6DS33` class. + First you will need to import the libraries to use the sensor + + .. code-block:: python + + import board + from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 + + Once this is done you can define your `board.I2C` object and define your sensor object + + .. code-block:: python + + i2c = board.I2C() # uses board.SCL and board.SDA + sensor = LSM6DS33(i2c) + + Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes + + .. code-block:: python + + acc_x, acc_y, acc_z = sensor.acceleration + gyro_x, gyro_z, gyro_z = sensor.gyro + + """ + + CHIP_ID = 0x6a From 3bc79ac821d84e81c4a13a49b21b467caefd5c54 Mon Sep 17 00:00:00 2001 From: Noel Gaetan Date: Wed, 6 Apr 2022 12:47:05 +0200 Subject: [PATCH 2/6] Fix misspelling --- adafruit_lsm6ds/lsm6ds3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adafruit_lsm6ds/lsm6ds3.py b/adafruit_lsm6ds/lsm6ds3.py index 6098d27..da60164 100644 --- a/adafruit_lsm6ds/lsm6ds3.py +++ b/adafruit_lsm6ds/lsm6ds3.py @@ -10,7 +10,7 @@ class LSM6DS3(LSM6DS): # pylint: disable=too-many-instance-attributes - """Driver for the LSM6DS33 6-axis accelerometer and gyroscope. + """Driver for the LSM6DS3 6-axis accelerometer and gyroscope. :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to. :param int address: The I2C device address. Defaults to :const:`0x6A` @@ -24,14 +24,14 @@ class LSM6DS3(LSM6DS): # pylint: disable=too-many-instance-attributes .. code-block:: python import board - from adafruit_lsm6ds.lsm6ds33 import LSM6DS33 + from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 Once this is done you can define your `board.I2C` object and define your sensor object .. code-block:: python i2c = board.I2C() # uses board.SCL and board.SDA - sensor = LSM6DS33(i2c) + sensor = LSM6DS3(i2c) Now you have access to the :attr:`acceleration` and :attr:`gyro`: attributes From b1f9cb114f2db4eb5ad05d802c855c2132d71ee3 Mon Sep 17 00:00:00 2001 From: Noel Gaetan Date: Wed, 6 Apr 2022 12:51:20 +0200 Subject: [PATCH 3/6] Create lsm6ds_lsm6ds3_simpletest.py --- examples/lsm6ds_lsm6ds3_simpletest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/lsm6ds_lsm6ds3_simpletest.py diff --git a/examples/lsm6ds_lsm6ds3_simpletest.py b/examples/lsm6ds_lsm6ds3_simpletest.py new file mode 100644 index 0000000..f5c021c --- /dev/null +++ b/examples/lsm6ds_lsm6ds3_simpletest.py @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries +# +# SPDX-License-Identifier: MIT +import time +import board +from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 + +i2c = board.I2C() # uses board.SCL and board.SDA +sensor = LSM6DS33(i2c) + +while True: + print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (sensor.acceleration)) + print("Gyro X:%.2f, Y: %.2f, Z: %.2f radians/s" % (sensor.gyro)) + print("") + time.sleep(0.5) From 5ef5153757f854066ebb079b4918c21e0688dceb Mon Sep 17 00:00:00 2001 From: Noel Gaetan Date: Wed, 6 Apr 2022 12:54:45 +0200 Subject: [PATCH 4/6] Fix bad error --- examples/lsm6ds_lsm6ds3_simpletest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lsm6ds_lsm6ds3_simpletest.py b/examples/lsm6ds_lsm6ds3_simpletest.py index f5c021c..62b69e4 100644 --- a/examples/lsm6ds_lsm6ds3_simpletest.py +++ b/examples/lsm6ds_lsm6ds3_simpletest.py @@ -6,7 +6,7 @@ from adafruit_lsm6ds.lsm6ds3 import LSM6DS3 i2c = board.I2C() # uses board.SCL and board.SDA -sensor = LSM6DS33(i2c) +sensor = LSM6DS3(i2c) while True: print("Acceleration: X:%.2f, Y: %.2f, Z: %.2f m/s^2" % (sensor.acceleration)) From aeffcc4d5ccb16bb48adb216399fda812120d2f5 Mon Sep 17 00:00:00 2001 From: Noel Gaetan Date: Wed, 6 Apr 2022 18:18:48 +0200 Subject: [PATCH 5/6] Update lsm6ds3.py --- adafruit_lsm6ds/lsm6ds3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_lsm6ds/lsm6ds3.py b/adafruit_lsm6ds/lsm6ds3.py index da60164..560da66 100644 --- a/adafruit_lsm6ds/lsm6ds3.py +++ b/adafruit_lsm6ds/lsm6ds3.py @@ -42,4 +42,4 @@ class LSM6DS3(LSM6DS): # pylint: disable=too-many-instance-attributes """ - CHIP_ID = 0x6a + CHIP_ID = 0x6A From e9206e33f9e4c753512f18ddd57368b4f8dc812e Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 2 May 2022 09:48:51 -0500 Subject: [PATCH 6/6] change copyright name for lsm6ds3 and change a few docs mentions to the proper model number --- adafruit_lsm6ds/lsm6ds3.py | 6 +++--- examples/lsm6ds_lsm6ds3_simpletest.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_lsm6ds/lsm6ds3.py b/adafruit_lsm6ds/lsm6ds3.py index 560da66..98d6525 100644 --- a/adafruit_lsm6ds/lsm6ds3.py +++ b/adafruit_lsm6ds/lsm6ds3.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries +# SPDX-FileCopyrightText: Copyright (c) 2022 Edrig # # SPDX-License-Identifier: MIT """ @@ -12,13 +12,13 @@ class LSM6DS3(LSM6DS): # pylint: disable=too-many-instance-attributes """Driver for the LSM6DS3 6-axis accelerometer and gyroscope. - :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS33 is connected to. + :param ~busio.I2C i2c_bus: The I2C bus the LSM6DS3 is connected to. :param int address: The I2C device address. Defaults to :const:`0x6A` **Quickstart: Importing and using the device** - Here is an example of using the :class:`LSM6DS33` class. + Here is an example of using the :class:`LSM6DS3` class. First you will need to import the libraries to use the sensor .. code-block:: python diff --git a/examples/lsm6ds_lsm6ds3_simpletest.py b/examples/lsm6ds_lsm6ds3_simpletest.py index 62b69e4..331daf7 100644 --- a/examples/lsm6ds_lsm6ds3_simpletest.py +++ b/examples/lsm6ds_lsm6ds3_simpletest.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries +# SPDX-FileCopyrightText: Copyright (c) 2022 Edrig # # SPDX-License-Identifier: MIT import time