A couple of observations:

   1. You're passing a 1-byte request to writeRead(), but specify a length
   of 2. This should throw an exception, not sure where it gets lost.
   2. I recommend checking the return value of writeRead(). When it is
   false, it means your device NAK'ed and the response buffer doesn't contain
   valid data.
   3. If this doesn't fix it, please describe which I2C device you're
   trying to talk to and how you've hooked things up.


On Thu, May 21, 2015 at 7:19 AM, Chris Do <[email protected]> wrote:

> So here's my code :
>
> private TwiMaster twi;
> byte[] response = new byte[2];
> //il faut addresser with adress
> byte[] request = new byte[] {0x48};
> double reception;
>
>
> void ioioSetup(IOIO ioio) throws ConnectionLostException
> {
>   twi = ioio.openTwiMaster(1, TwiMaster.Rate.RATE_400KHz, false);
> }
>
>
> void ioioLoop(IOIO ioio) throws ConnectionLostException
> {
>   try
>   {
>     twi.writeRead(72, false, request, 2, response, 2);
>     double reception = (double)(((response[1] & 0x007f) << 8) + response[0
> ]);
>     //reception = (reception * 0.0625);
>     Thread.sleep(100);
>   }
>   catch (InterruptedException e)
>   {
>   }
> }
>
> I know that you don't know Processing but as you said i could use the git
> hub page and you are the one who made this. I thought you could help me
> make this work because when i display it on my tablet there s jjust 0.00 ..
> Thanks, have a good day.
>
> --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to