REVrobotics / 2m-Distance-Sensor

Port of ST vl53l0x driver for roboRIO to operate the REV Robotics 2m Distance Sensor.
http://www.revrobotics.com/rev-31-1505/
BSD 3-Clause "New" or "Revised" License
6 stars 8 forks source link

Allow changingI2C address of the sensor #10

Open jeffding45 opened 4 years ago

jeffding45 commented 4 years ago

Hello. Can we add a parameter to the constructor of the Rev2mDistanceSensor class to to override the I2C address? We figured out a way to change the address of the device at power-up so this would be useful to enable multiple devices on the same I2C bus.

willtoth commented 4 years ago

Are you planning on using a multiplexer? If so you probably don't actually need to set the address at all since the mux takes care of that.

jeffding45 commented 4 years ago

We experimented with a multiplexer, but have since ruled it out due to the way the distance sensor code works. Since it spins up a thread to communicate with the sensors behind the scenes, it isn't going to be happy if it loses ability to talk with the sensors as the mux switches between sensors.

We have since modified the Rev2mDistanceSensor class and added functionality to the constructor to pass in an I2C address. If the address is different from the default, we call the function to change the address. This approach is working well. We're now bread boarding our hardware solution to power up the sensors one at a time in order to initialize and change the address of each sensor individually.

Once we have a solid solution we can upload our changes to the code and you can merge as you see fit.

nimrod46 commented 2 years ago

@jeffding45 Have you finished working on the code? Are you able to share it with us?