Skip to content

mode setter appears wrong #26

@peterhinch

Description

@peterhinch

I'm writing a MicroPython driver for your board. In my testing it is only possible to change the device mode if you first change the mode to _CONFIG_MODE. Unfortunately I don't have any hardware capable of running CircuitPython but I think the following test will fail:

import adafruit_bno055
from busio import I2C
from board import SDA, SCL

i2c = I2C(SCL, SDA)
imu = adafruit_bno055.BNO055(i2c)
print(imu.euler)  # Check it's working
imu.mode = 5
print(imu.mode)  # I think this will be unchanged

The need to set _CONFIG_MODE prior to setting any other mode is contradicted in the chip datasheet (section 3.3.1). Consequently before I submit a PR I would be grateful if someone could perform the above test to confirm my findings.

For reference this is my mode setting code. This includes delays mandated by the device datasheet.

    def mode(self, new_mode=None):
        old_mode = self._read(_MODE_REGISTER)
        if new_mode is not None:
            self._write(_MODE_REGISTER, _CONFIG_MODE)  # This is empirically necessary if the mode is to be changed
            time.sleep_ms(20)  # Datasheet table 3.6
            if new_mode != _CONFIG_MODE:
                self._write(_MODE_REGISTER, new_mode)
                time.sleep_ms(10)  # Table 3.6
        return old_mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions