I have tested the code from the snapshot (April 6'th) and I think I have found a bug or mistake from your side.
In this thread gloomyandy say that one should always call i2cComplete after an i2cStart. I know this is for lejos 0.8.5, but is this also true for the new version?
For me it seems like that, because you have them both in the i2cTransaction method.
Why do one need to call i2cComplete after an i2cStart, if one just want to send bytes??
You have abstracted away the two low level methods (i2cStart and i2cComplete) in the new lejos. I can't call them from an I2CPort anymore.
The problem comes when you for example want to change the address of an Mindsensor sensor, in the datasheet they say:
Changing the I2C Bus Address:
The I2C bus address of DIST-Nx can be changed. To set an address
different from default address, send sequence of following
commands on the command register:
0xA0, 0xAA, 0xA5, <new I2C address>
Note: Send these commands with no break/read operation in
between. This new address is effective immediately. Please note
down your address carefully for future reference.
The fact that the sensor don't allow any break/read operation in between cause problems.
To make it work I use
- Code: Select all
SensorPort.S1.i2cStart(old, new byte[]{0x41, (byte)0xA0}, 0, 2, 0);
Delay.msDelay(50);
SensorPort.S1.i2cStart(old, new byte[]{0x41, (byte)0xAA}, 0, 2, 0);
Delay.msDelay(50);
SensorPort.S1.i2cStart(old, new byte[]{0x41, (byte)0xA5}, 0, 2, 0);
Delay.msDelay(50);
SensorPort.S1.i2cStart(old, new byte[]{0x41, (byte)newAddress}, 0, 2, 0);
Delay.msDelay(50);
I think this code is very odd, and I can't make a general solution for an arbitrary sensor port. I would suggest you to at least have the i2cStart left in the I2CPort interface. Or some other solution to just send data.
In addition I have some problem with more than one I2C sensor on the same port. Maybe it's the same bug that fail activation of ADPA. But it can as well be my electronic skills that cause that...
