adafruit / Adafruit_CircuitPython_BNO055

CircuitPython driver for BNO055 absolute orientation sensor
MIT License
85 stars 51 forks source link

Some mode setters seem to have no effect #124

Open FreddiEichhorn opened 2 weeks ago

FreddiEichhorn commented 2 weeks ago

Some of the mode setters seem to have no effect. Specifically, these are the setters for gyro bandwith, gyro range and accel range. There may be others too that I havent tried. Some minimal code for reproduction:

import adafruit_bno055 import board

def main(): i2c = board.I2C() sensor = adafruit_bno055.BNO055_I2C(i2c)

sensor.mode = adafruit_bno055.AMG_MODE  # Needs to not be fusion mode
print('Gyro range before ', sensor.gyro_range)
sensor.gyro_range = adafruit_bno055.GYRO_125_DPS
print('Gyro range after ', sensor.gyro_range, ' should be ', adafruit_bno055.GYRO_125_DPS)
print('Gyro bandwidth before ', sensor.gyro_bandwidth)
sensor.gyro_bandwidth = adafruit_bno055.GYRO_116HZ
print('Gyro bandwidth after ', sensor.gyro_bandwidth, ' should be ', adafruit_bno055.GYRO_116HZ)
print('Accel range before ', sensor.accel_range)
sensor.accel_range = adafruit_bno055.ACCEL_2G
print('Accel range after ', sensor.accel_range, ' should be ', adafruit_bno055.ACCEL_2G)
FreddiEichhorn commented 2 weeks ago

After looking at the datasheet, I've realized that the sensor needs to be in config mode to change these settings. I think the appropriate setter methods should check for this and either throw a warning or change sensor mode accordingly.