class Looper extends BaseIOIOLooper {

    public void setup() throws ConnectionLostException {

        twi = ioio_.openTwiMaster(0, TwiMaster.Rate.RATE_100KHz, false);

        runOnUiThread(new Runnable() { 

             public void run() { 

                 Toast.makeText(getApplicationContext(), 

                         "TMP102 Connected!", Toast.LENGTH_SHORT).show(); 

                }        

            });

 }

  public void loop() throws ConnectionLostException, InterruptedException {

   try {

     twi.writeRead(address, false, request, 1, response, 2);

     setText(response.toString());

   } catch (InterruptedException e) {

     ioio_.disconnect();

   } catch (ConnectionLostException e) {

     throw e;

   }

 }

}

 protected IOIOLooper createIOIOLooper() {

        return new Looper();

}

 public float getTemperature() throws Exception {

    int temp = Temp.from(response[0]) << 8 | Temp.from(response[1]);

   temp >>= 4;

   return temp / 16.f + 273.15f; 

}

 private void setText(final String str) {

   runOnUiThread(new Runnable() {

      @Override

      public void run() {

      tmpTextView.setText(str);

 }

 });

}

-- 
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