SwerveRobotics / ftc_app

FTC robot controllers ++
15 stars 38 forks source link

Word Read/Write in I2cDeviceClient? #56

Closed luciengaitskell closed 8 years ago

luciengaitskell commented 8 years ago

Is there any capability for word read and writes in the I2cDeviceClient class. If not, is there any planned?

luciengaitskell commented 8 years ago

I have a MaxSonar Ultrasound sensor with requires a word read. Also, I have a led which changes color using three bytes. Is there any way to work with these with the current library?

rgatkinson commented 8 years ago

Sure. The easiest way is to read the bytes as a byte array, then use a ByteBuffer (I think it’s called; I’m away from my main machine at the moment) to convert that to an integer, either little endian, or big endian, as appropriate.

luciengaitskell commented 8 years ago

Another question, what do I put in for the "OpMode context" in the "ClassFactory.createI2cDeviceClient()"?

rgatkinson commented 8 years ago

Just pass the instance of the (subclass of) OpMode that you are running.

luciengaitskell commented 8 years ago

Ok. Why is it needed?

luciengaitskell commented 8 years ago

I'm trying to use multiple sensors on the same port using your I2cDeviceClient library, yet I seems to hang the OpMode when I try to interface to both at the same time. Is it possible to interface multiple sensors on one port using your library?

rgatkinson commented 8 years ago

Using multiple sensors on one port is not something that is supported. Is that important to you? Can you help us understand by illustrating with an example?