From dd263710b844b69c149121e1b11ad68844976818 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 30 Jun 2020 15:24:22 -0400 Subject: [PATCH 1/3] Added documentation for modes --- adafruit_bno055.py | 136 +++++++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 36 deletions(-) diff --git a/adafruit_bno055.py b/adafruit_bno055.py index 10fd1be..cef0ac2 100644 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -143,44 +143,108 @@ def _reset(self): @property def mode(self): """ - Switch the mode of operation and return the previous mode. - - Mode of operation defines which sensors are enabled and whether the - measurements are absolute or relative. - If a sensor is disabled, it will return an empty tuple. - - legend: x=on, -=off - +------------------+-------+---------+------+----------+ - | Mode | Accel | Compass | Gyro | Absolute | - +==================+=======+=========+======+==========+ - | CONFIG_MODE | - | - | - | - | - +------------------+-------+---------+------+----------+ - | ACCONLY_MODE | X | - | - | - | - +------------------+-------+---------+------+----------+ - | MAGONLY_MODE | - | X | - | - | - +------------------+-------+---------+------+----------+ - | GYRONLY_MODE | - | - | X | - | - +------------------+-------+---------+------+----------+ - | ACCMAG_MODE | X | X | - | - | - +------------------+-------+---------+------+----------+ - | ACCGYRO_MODE | X | - | X | - | - +------------------+-------+---------+------+----------+ - | MAGGYRO_MODE | - | X | X | - | - +------------------+-------+---------+------+----------+ - | AMG_MODE | X | X | X | - | - +------------------+-------+---------+------+----------+ - | IMUPLUS_MODE | X | - | X | - | - +------------------+-------+---------+------+----------+ - | COMPASS_MODE | X | X | - | X | - +------------------+-------+---------+------+----------+ - | M4G_MODE | X | X | - | - | - +------------------+-------+---------+------+----------+ - | NDOF_FMC_OFF_MODE| X | X | X | X | - +------------------+-------+---------+------+----------+ - | NDOF_MODE | X | X | X | X | - +------------------+-------+---------+------+----------+ + .. code-block:: + + legend: x=on, -=off + +------------------+-------+---------+------+----------+ + | Mode | Accel | Compass | Gyro | Absolute | + +==================+=======+=========+======+==========+ + | CONFIG_MODE | - | - | - | - | + +------------------+-------+---------+------+----------+ + | ACCONLY_MODE | X | - | - | - | + +------------------+-------+---------+------+----------+ + | MAGONLY_MODE | - | X | - | - | + +------------------+-------+---------+------+----------+ + | GYRONLY_MODE | - | - | X | - | + +------------------+-------+---------+------+----------+ + | ACCMAG_MODE | X | X | - | - | + +------------------+-------+---------+------+----------+ + | ACCGYRO_MODE | X | - | X | - | + +------------------+-------+---------+------+----------+ + | MAGGYRO_MODE | - | X | X | - | + +------------------+-------+---------+------+----------+ + | AMG_MODE | X | X | X | - | + +------------------+-------+---------+------+----------+ + | IMUPLUS_MODE | X | - | X | - | + +------------------+-------+---------+------+----------+ + | COMPASS_MODE | X | X | - | X | + +------------------+-------+---------+------+----------+ + | M4G_MODE | X | X | - | - | + +------------------+-------+---------+------+----------+ + | NDOF_FMC_OFF_MODE| X | X | X | X | + +------------------+-------+---------+------+----------+ + | NDOF_MODE | X | X | X | X | + +------------------+-------+---------+------+----------+ The default mode is ``NDOF_MODE``. + + | You can set the mode using the line below: + | ``sensor.mode = adafruit_bno055.ACCONLY_MODE`` + | replacing ``ACCONLY_MODE`` with the mode you want to use + + .. data:: CONFIG_MODE + + This mode is used to configure BNO, wherein all output data is reset to zero and sensor fusion + is halted. + + .. data:: ACCONLY_MODE + + In this mode, the BNO055 behaves like a stand-alone acceleration sensor. In this mode the + other sensors (magnetometer, gyro) are suspended to lower the power consumption. + + .. data:: MAGONLY_MODE + + In MAGONLY mode, the BNO055 behaves like a stand-alone magnetometer, with acceleration sensor + and gyroscope being suspended. + + .. data:: GYRONLY_MODE + + In GYROONLY mode, the BNO055 behaves like a stand-alone gyroscope, with acceleration sensor and + magnetometer being suspended. + + .. data:: ACCMAG_MODE + + Both accelerometer and magnetometer are switched on, the user can read the data from these two + sensors. + + .. data:: ACCGYRO_MODE + + Both accelerometer and gyroscope are switched on; the user can read the data from these two + sensors. + + .. data:: MAGGYRO_MODE + + Both magnetometer and gyroscope are switched on, the user can read the data from these two + sensors. + + .. data:: AMG_MODE + + All three sensors accelerometer, magnetometer and gyroscope are switched on. + + .. data:: IMUPLUS_MODE + + In the IMU mode the relative orientation of the BNO055 in space is calculated from the + accelerometer and gyroscope data. The calculation is fast (i.e. high output data rate). + + .. data:: COMPASS_MODE + + The COMPASS mode is intended to measure the magnetic earth field and calculate the geographic + direction. + + .. data:: M4G_MODE + + The M4G mode is similar to the IMU mode, but instead of using the gyroscope signal to detect + rotation, the changing orientation of the magnetometer in the magnetic field is used. + + .. data:: NDOF_FMC_OFF_MODE + + This fusion mode is same as NDOF mode, but with the Fast Magnetometer Calibration turned ‘OFF’. + + .. data:: NDOF_MODE + + This is a fusion mode with 9 degrees of freedom where the fused absolute orientation data is + calculated from accelerometer, gyroscope and the magnetometer. + """ return self._read_register(_MODE_REGISTER) From 57aaba408fcc584e0adbbbbb4786b81329f6a4f4 Mon Sep 17 00:00:00 2001 From: dherrada Date: Tue, 30 Jun 2020 15:28:31 -0400 Subject: [PATCH 2/3] Linted --- adafruit_bno055.py | 40 +++++++++++++++++++++------------------- docs/conf.py | 12 ++++-------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/adafruit_bno055.py b/adafruit_bno055.py index cef0ac2..944356f 100644 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -184,8 +184,8 @@ def mode(self): .. data:: CONFIG_MODE - This mode is used to configure BNO, wherein all output data is reset to zero and sensor fusion - is halted. + This mode is used to configure BNO, wherein all output data is reset to zero and sensor + fusion is halted. .. data:: ACCONLY_MODE @@ -194,28 +194,28 @@ def mode(self): .. data:: MAGONLY_MODE - In MAGONLY mode, the BNO055 behaves like a stand-alone magnetometer, with acceleration sensor - and gyroscope being suspended. + In MAGONLY mode, the BNO055 behaves like a stand-alone magnetometer, with acceleration + sensor and gyroscope being suspended. .. data:: GYRONLY_MODE - In GYROONLY mode, the BNO055 behaves like a stand-alone gyroscope, with acceleration sensor and - magnetometer being suspended. + In GYROONLY mode, the BNO055 behaves like a stand-alone gyroscope, with acceleration + sensor and magnetometer being suspended. .. data:: ACCMAG_MODE - Both accelerometer and magnetometer are switched on, the user can read the data from these two - sensors. + Both accelerometer and magnetometer are switched on, the user can read the data from + these two sensors. .. data:: ACCGYRO_MODE - Both accelerometer and gyroscope are switched on; the user can read the data from these two - sensors. + Both accelerometer and gyroscope are switched on; the user can read the data from these + two sensors. .. data:: MAGGYRO_MODE - Both magnetometer and gyroscope are switched on, the user can read the data from these two - sensors. + Both magnetometer and gyroscope are switched on, the user can read the data from these + two sensors. .. data:: AMG_MODE @@ -228,22 +228,24 @@ def mode(self): .. data:: COMPASS_MODE - The COMPASS mode is intended to measure the magnetic earth field and calculate the geographic - direction. + The COMPASS mode is intended to measure the magnetic earth field and calculate the + geographic direction. .. data:: M4G_MODE - The M4G mode is similar to the IMU mode, but instead of using the gyroscope signal to detect - rotation, the changing orientation of the magnetometer in the magnetic field is used. + The M4G mode is similar to the IMU mode, but instead of using the gyroscope signal to + detect rotation, the changing orientation of the magnetometer in the magnetic field is + used. .. data:: NDOF_FMC_OFF_MODE - This fusion mode is same as NDOF mode, but with the Fast Magnetometer Calibration turned ‘OFF’. + This fusion mode is same as NDOF mode, but with the Fast Magnetometer Calibration turned + ‘OFF’. .. data:: NDOF_MODE - This is a fusion mode with 9 degrees of freedom where the fused absolute orientation data is - calculated from accelerometer, gyroscope and the magnetometer. + This is a fusion mode with 9 degrees of freedom where the fused absolute orientation data + is calculated from accelerometer, gyroscope and the magnetometer. """ return self._read_register(_MODE_REGISTER) diff --git a/docs/conf.py b/docs/conf.py index c5429f0..66b2325 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,16 +10,12 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.intersphinx", - "sphinx.ext.viewcode", -] +extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.viewcode"] # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -# autodoc_mock_imports = ["adafruit_bus_device", "micropython", "adafruit_register"] +autodoc_mock_imports = ["adafruit_bus_device", "micropython", "adafruit_register"] intersphinx_mapping = { "python": ("https://docs.python.org/3.4", None), @@ -144,7 +140,7 @@ "Adafruit BNO055 Library Documentation", "Radomir Dopieralski", "manual", - ), + ) ] # -- Options for manual page output --------------------------------------- @@ -175,5 +171,5 @@ "AdafruitBNO055Library", "One line description of project.", "Miscellaneous", - ), + ) ] From 9f950aae02ab0634dcdad375afa066a9fdc8e6cb Mon Sep 17 00:00:00 2001 From: dherrada Date: Wed, 1 Jul 2020 17:55:53 -0400 Subject: [PATCH 3/3] Fixed table --- adafruit_bno055.py | 63 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/adafruit_bno055.py b/adafruit_bno055.py index 944356f..312b451 100644 --- a/adafruit_bno055.py +++ b/adafruit_bno055.py @@ -143,38 +143,37 @@ def _reset(self): @property def mode(self): """ - .. code-block:: - - legend: x=on, -=off - +------------------+-------+---------+------+----------+ - | Mode | Accel | Compass | Gyro | Absolute | - +==================+=======+=========+======+==========+ - | CONFIG_MODE | - | - | - | - | - +------------------+-------+---------+------+----------+ - | ACCONLY_MODE | X | - | - | - | - +------------------+-------+---------+------+----------+ - | MAGONLY_MODE | - | X | - | - | - +------------------+-------+---------+------+----------+ - | GYRONLY_MODE | - | - | X | - | - +------------------+-------+---------+------+----------+ - | ACCMAG_MODE | X | X | - | - | - +------------------+-------+---------+------+----------+ - | ACCGYRO_MODE | X | - | X | - | - +------------------+-------+---------+------+----------+ - | MAGGYRO_MODE | - | X | X | - | - +------------------+-------+---------+------+----------+ - | AMG_MODE | X | X | X | - | - +------------------+-------+---------+------+----------+ - | IMUPLUS_MODE | X | - | X | - | - +------------------+-------+---------+------+----------+ - | COMPASS_MODE | X | X | - | X | - +------------------+-------+---------+------+----------+ - | M4G_MODE | X | X | - | - | - +------------------+-------+---------+------+----------+ - | NDOF_FMC_OFF_MODE| X | X | X | X | - +------------------+-------+---------+------+----------+ - | NDOF_MODE | X | X | X | X | - +------------------+-------+---------+------+----------+ + legend: x=on, -=off + + +------------------+-------+---------+------+----------+ + | Mode | Accel | Compass | Gyro | Absolute | + +==================+=======+=========+======+==========+ + | CONFIG_MODE | - | - | - | - | + +------------------+-------+---------+------+----------+ + | ACCONLY_MODE | X | - | - | - | + +------------------+-------+---------+------+----------+ + | MAGONLY_MODE | - | X | - | - | + +------------------+-------+---------+------+----------+ + | GYRONLY_MODE | - | - | X | - | + +------------------+-------+---------+------+----------+ + | ACCMAG_MODE | X | X | - | - | + +------------------+-------+---------+------+----------+ + | ACCGYRO_MODE | X | - | X | - | + +------------------+-------+---------+------+----------+ + | MAGGYRO_MODE | - | X | X | - | + +------------------+-------+---------+------+----------+ + | AMG_MODE | X | X | X | - | + +------------------+-------+---------+------+----------+ + | IMUPLUS_MODE | X | - | X | - | + +------------------+-------+---------+------+----------+ + | COMPASS_MODE | X | X | - | X | + +------------------+-------+---------+------+----------+ + | M4G_MODE | X | X | - | - | + +------------------+-------+---------+------+----------+ + | NDOF_FMC_OFF_MODE| X | X | X | X | + +------------------+-------+---------+------+----------+ + | NDOF_MODE | X | X | X | X | + +------------------+-------+---------+------+----------+ The default mode is ``NDOF_MODE``.