I have a TPA81 and I can read a pixel a time and get the correct results.
But if I read all values in one time to an array, when I read the result array it looses values.
I can’t read all the values. Is there an explanation?
The code:
byte[] result = new byte[9];
SoftwareI2CBus.I2CDevice tpa81 = i2c.CreateI2CDevice(
(ushort)(0xD0 >> 1) ,
0 );
int read;
int writen;
tpa81.WriteRead(new byte[] { 0x01 }, 0, 1, result, 0, 9, out writen, out read);
Debug.Print("AMBIENT: " + result[0]);
for (int i =1; i <9; i++)
Debug.Print("PIXEL" + i + ": " + result[i]);
Example of output (it should have Ambient and 8 pixels):
/*
Output:
Reading from TPA81 successfull, time: 1
Pixel 1: 16
Pixel 2: 15
Pixel 3: 22
Pixel 4: 16
Pixel 5: 21
Pixel 6: 17
Reading from TPA81 successfull, time: 1
Pixel 1: 17
Pixel 4: 15
Pixel 5: 21
Pixel 6: 17
Pixel 7: 21
Reading from TPA81 successfull, time: 1
Ambiente:17
Pixel 1: 14
Pixel 2: 16
Pixel 3: 14
Pixel 6: 17
Reading from TPA81 successfull, time: 1
Ambiente:17
Pixel 0: 17
Pixel 3: 12
Pixel 5: 24
Pixel 6: 20
Pixel 7: 17
Pixel 8: 17
*/