-
Notifications
You must be signed in to change notification settings - Fork 53
Added ability to configure accelerometer #51
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
Edit: I guess it fixed itself |
CircuitPython libraries favor using properties instead of getter/setter functions, see here: So you are essentially wanting to add 3 properties:
There are already several properties defined in this library you can use as a reference. Also, be careful about Page 0 vs. Page 1 registers. You want to make sure you are accessing register 0x08 from Page 1. I'm not seeing anything that currently access anything in Page 1. But there is at least a |
@caternuson Thanks for taking a look at this. I'll make those changes now. |
@caternuson Do you think it'd be worth adding the configuration for the gyro and magnetometer? It should be pretty much just copying and pasting the current code I've got (I've made the changes you asked, just have to test). |
Sure. Might as well. To keep things clear as to what sensor a parameter is related to, how about these naming prefixes?
ex: |
@caternuson Yeah, I think that makes sense |
@caternuson I have tested this and it does work well. The only issue arises when you're trying to use more than one non-fusion mode in the same run since the registers can't be written to even after the mode is switched. I seem to recall encountering this a few months ago, and I thought the issue was on the side of the bno055, but I could be completely misremembering. |
Your getters change to Page 1 then set back to Page 0. But none of the setters do that. Is that OK? |
I think so. That being said, I'd feel better about the chances this could cause an issue later on if I had it change back to page 0, so I'll do that. |
Ah - just noticed the return type is string, because of use of Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_bno055
>>> bno = adafruit_bno055.BNO055_I2C(board.I2C())
>>> bno.accel_range
'0b1'
>>> range = bno.accel_range
>>> bno.accel_range = range
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_bno055.py", line 407, in accel_range
TypeError: can't convert 'int' object to str implicitly
>>> It also allows for comparisons, ex: >>> adafruit_bno055.ACCEL_4G
1
>>> bno.accel_range
'0b1'
>>> bno.accel_range == adafruit_bno055.ACCEL_4G
False
>>> That should have been |
@caternuson Ah, yeah. That definitely makes sense. I was wanting to display it 'visually' in binary since it is a lot easier to see what's going on that way, but it's definitely a lot better for it to return an int. |
One more suggestion added. But those last updates are working better: Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_bno055
>>> bno = adafruit_bno055.BNO055_I2C(board.I2C())
>>> range = bno.accel_range
>>> bno.accel_range = range
>>> bno.accel_range == adafruit_bno055.ACCEL_4G
True
>>> |
Cool. OK, calling it good at this point. Thanks for all the updates. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.2.0 from 5.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#51 from adafruit/accel_config Updating https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO to 4.0.0 from 3.3.3: > Merge pull request adafruit/Adafruit_CircuitPython_AdafruitIO#43 from brentru/fix-attribute-error > Merge pull request adafruit/Adafruit_CircuitPython_AdafruitIO#41 from 2bndy5/master Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Added the following libraries: Adafruit_CircuitPython_MS8607
I can do this with the other sensors as well if you'd like me to.