-
Notifications
You must be signed in to change notification settings - Fork 53
mode setter enables changes and honors delays. #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.
adafruit_bno055.py
Outdated
@@ -197,6 +197,14 @@ def mode(self): | |||
""" | |||
return self._read_register(_MODE_REGISTER) | |||
|
|||
@mode.setter | |||
def mode(self, new_mode): | |||
self._write_register(_MODE_REGISTER, _CONFIG_MODE) # Empirically necessary |
There was a problem hiding this comment.
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
adafruit_bno055.py
Outdated
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adafruit_bno055.py
Outdated
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: |
There was a problem hiding this comment.
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
You are right. Now updated. |
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
>>> |
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
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.