Skip to content
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

Experimental multiple i2c bus support #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gadgetoid
Copy link
Member

This is an experimental fix for #33 (I have no hardware to test locally, so I've only tested that this compiles).

It fixes the issue of the i2c read/write and multi functions being global, so that if you attempted to initialise several sensors on different i2c busses then you'd only actually be talking to the last initialised bus, since the read/write/multi function pointers were being overwritten.

This is achieved by moving the i2c IO functions into VL53L1_DEV and passing them in through _TOF_LIBRARY.initialise instead of _TOF_LIBRARY.VL53L1_set_i2c.

This should have no impact on existing setups.

It might be worth also moving the i2c mutex into VL53L1_DEV, since it only needs to be per i2c bus.

@nav2u
Copy link

nav2u commented Mar 17, 2020

It looks like this code update fixes the issue. I get five individual distance readings now with five sensors, which I confirmed by blocking each sensor individually. Thank you!

@Gadgetoid
Copy link
Member Author

Wow. I'm actually a little surprised it hasn't subtly broken. Thanks for reporting back.

@nav2u
Copy link

nav2u commented Mar 17, 2020

No problems, thank you for taking the time to help out 👍

I will be messing with these sensors for the next few weeks, so you'll probably hear more from me on here :)

@Gadgetoid Gadgetoid force-pushed the multiple-i2c-bus-support branch from 2307bd5 to 7b06138 Compare February 10, 2022 16:12
@DmitryBrown
Copy link

Would love some help on this! I cloned the multiple-i2c-bus-support branch. I also set up two additional physical i2c busses by retagging 4 gpio pins. However i'm still running into issues described - one sensor reading is applied to all three.

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.

3 participants