Skip to content

Conversation

@peterhinch
Copy link
Contributor

This fixes two issues with the mode setter.

Firstly, as per issue #26, it is necessary to set _CONFIG_MODE prior to making any other mode change. The datasheet is misleading on this but it is empirically necessary.

Secondly the datasheet mandates delays after setting and clearing _CONFIG_MODE.

Please note that I have no means of running CircuitPython: I have tested this code against MicroPython only.

Copy link
Contributor

@caternuson caternuson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Looks like there are a few minor corrections needed, which I've noted in the review.


@mode.setter
def mode(self, new_mode):
self._write_register(_MODE_REGISTER, _CONFIG_MODE) # Empirically necessary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_CONFIG_MODE is not defined, needs to be CONFIG_MODE

@mode.setter
def mode(self, new_mode):
self._write_register(_MODE_REGISTER, _CONFIG_MODE) # Empirically necessary
time.sleep_ms(0.02) # Datasheet table 3.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be time.sleep(0.02).
image

def mode(self, new_mode):
self._write_register(_MODE_REGISTER, _CONFIG_MODE) # Empirically necessary
time.sleep_ms(0.02) # Datasheet table 3.6
if new_mode != _CONFIG_MODE:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for _CONFIG_MODE

@peterhinch
Copy link
Contributor Author

You are right. Now updated.

@caternuson caternuson requested a review from a team May 5, 2019 14:25
@caternuson
Copy link
Contributor

Looks good. Tested:

Adafruit CircuitPython 3.1.2 on 2019-01-07; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import adafruit_bno055
>>> from busio import I2C
>>> from board import SDA, SCL
>>> i2c = I2C(SCL, SDA)
>>> imu = adafruit_bno055.BNO055(i2c)
>>> imu.mode
12
>>> imu.mode = 5
>>> imu.mode
5
>>>

@caternuson caternuson merged commit d48ec14 into adafruit:master May 9, 2019
@peterhinch peterhinch deleted the mode-fix branch May 10, 2019 09:11
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 10, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 2.0.0 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#28 from caternuson/iss26_continuous
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#31 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_AMG88xx to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_AMG88xx#14 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 3.0.6 from 3.0.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#27 from peterhinch/mode-fix
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#25 from peterhinch/issues_23_24

Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 3.3.2 from 3.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#23 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH to 4.3.5 from 4.3.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3DH#50 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX7219 to 1.2.1 from 1.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_MAX7219#19 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_MLX90393 to 1.2.1 from 1.2.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_MLX90393#9 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPL3115A2#5 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_MPR121 to 2.0.2 from 2.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MPR121#18 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.0.1 from 3.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#33 from ChewyTurtle/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_SI5351 to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SI5351#5 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1306 to 2.6.3 from 2.6.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1306#25 from dherrada/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_AVRprog to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_AVRprog#8 from dherrada/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants