Compare commits
No commits in common. "master" and "accel_config" have entirely different histories.
master
...
accel_conf
3 changed files with 18 additions and 123 deletions
|
|
@ -205,8 +205,13 @@ class BNO055: # pylint: disable=too-many-public-methods
|
|||
@property
|
||||
def mode(self):
|
||||
"""
|
||||
legend: x=on, -=off
|
||||
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 |
|
||||
+==================+=======+=========+======+==========+
|
||||
|
|
@ -238,76 +243,6 @@ class BNO055: # pylint: disable=too-many-public-methods
|
|||
+------------------+-------+---------+------+----------+
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -697,9 +632,7 @@ class BNO055_UART(BNO055):
|
|||
if not isinstance(data, bytes):
|
||||
data = bytes([data])
|
||||
self._uart.write(bytes([0xAA, 0x00, register, len(data)]) + data)
|
||||
now = time.monotonic()
|
||||
while self._uart.in_waiting < 2 and time.monotonic() - now < 0.25:
|
||||
pass
|
||||
time.sleep(0.1)
|
||||
resp = self._uart.read(self._uart.in_waiting)
|
||||
if len(resp) < 2:
|
||||
raise OSError("UART access error.")
|
||||
|
|
@ -707,16 +640,9 @@ class BNO055_UART(BNO055):
|
|||
raise RuntimeError("UART write error: {}".format(resp[1]))
|
||||
|
||||
def _read_register(self, register, length=1): # pylint: disable=arguments-differ
|
||||
i = 0
|
||||
while i < 3:
|
||||
self._uart.write(bytes([0xAA, 0x01, register, length]))
|
||||
now = time.monotonic()
|
||||
while self._uart.in_waiting < length + 2 and time.monotonic() - now < 0.1:
|
||||
pass
|
||||
resp = self._uart.read(self._uart.in_waiting)
|
||||
if len(resp) >= 2 and resp[0] == 0xBB:
|
||||
break
|
||||
i += 1
|
||||
self._uart.write(bytes([0xAA, 0x01, register, length]))
|
||||
time.sleep(0.1)
|
||||
resp = self._uart.read(self._uart.in_waiting)
|
||||
if len(resp) < 2:
|
||||
raise OSError("UART access error.")
|
||||
if resp[0] != 0xBB:
|
||||
|
|
|
|||
12
docs/conf.py
12
docs/conf.py
|
|
@ -10,12 +10,16 @@ sys.path.insert(0, os.path.abspath(".."))
|
|||
# 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),
|
||||
|
|
@ -140,7 +144,7 @@ latex_documents = [
|
|||
"Adafruit BNO055 Library Documentation",
|
||||
"Radomir Dopieralski",
|
||||
"manual",
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
|
@ -171,5 +175,5 @@ texinfo_documents = [
|
|||
"AdafruitBNO055Library",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
)
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
"""
|
||||
This example demonstrates how to instantiate the
|
||||
Adafruit BNO055 Sensor using this library and just
|
||||
the I2C bus number.
|
||||
This example will only work on a Raspberry Pi
|
||||
and does require the i2c-gpio kernel module to be
|
||||
installed and enabled. Most Raspberry Pis will
|
||||
already have it installed, however most do not
|
||||
have it enabled. You will have to manually enable it
|
||||
"""
|
||||
|
||||
import time
|
||||
from adafruit_extended_bus import ExtendedI2C as I2C
|
||||
import adafruit_bno055
|
||||
|
||||
# To enable i2c-gpio, add the line `dtoverlay=i2c-gpio` to /boot/config.txt
|
||||
# Then reboot the pi
|
||||
|
||||
# Create library object using our Extended Bus I2C port
|
||||
# Use `ls /dev/i2c*` to find out what i2c devices are connected
|
||||
i2c = I2C(1) # Device is /dev/i2c-1
|
||||
sensor = adafruit_bno055.BNO055_I2C(i2c)
|
||||
|
||||
while True:
|
||||
print("Temperature: {} degrees C".format(sensor.temperature))
|
||||
print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
|
||||
print("Magnetometer (microteslas): {}".format(sensor.magnetic))
|
||||
print("Gyroscope (rad/sec): {}".format(sensor.gyro))
|
||||
print("Euler angle: {}".format(sensor.euler))
|
||||
print("Quaternion: {}".format(sensor.quaternion))
|
||||
print("Linear acceleration (m/s^2): {}".format(sensor.linear_acceleration))
|
||||
print("Gravity (m/s^2): {}".format(sensor.gravity))
|
||||
print()
|
||||
|
||||
time.sleep(1)
|
||||
Loading…
Reference in a new issue