It should be periodically called from loop() and the result sent to the UI
widget (TextView).
On Mar 24, 2014 1:45 PM, "Marius Vosylius" <[email protected]>
wrote:

> getTemperature should be outside Looper class?
>
> On Monday, March 24, 2014 8:35:57 PM UTC, Ytai wrote:
>>
>> Read my previous post please (about IOIOSimpleApp)
>>
>>
>> On Mon, Mar 24, 2014 at 1:33 PM, Marius Vosylius <[email protected]>wrote:
>>
>>> what do In need to have in a loop?
>>>
>>>
>>> On Monday, March 24, 2014 8:27:40 PM UTC, Ytai wrote:
>>>
>>>> Where's your loop() method? The getTemperature() method doesn't seem to
>>>> be called from anywhere...
>>>>
>>>>
>>>> On Mon, Mar 24, 2014 at 12:32 PM, Marius Vosylius <[email protected]
>>>> > wrote:
>>>>
>>>>>  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 float getTemperature() throws Exception {
>>>>>>>
>>>>>>>    if (!twi.writeRead(address, false, request, 1, response, 2)) {
>>>>>>>
>>>>>>>    throw new Exception("I2C transaction with TMP102 failed.");
>>>>>>>
>>>>>>>  }
>>>>>>>
>>>>>>>  int temp = Temp.from(response[0]) << 8 | Temp.from(response[1]);
>>>>>>>
>>>>>>>  temp >>= 4;
>>>>>>>
>>>>>>>  return temp / 16.f + 273.15f;
>>>>>>>
>>>>>>>   }
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>>  protected IOIOLooper createIOIOLooper() {
>>>>>>>
>>>>>>>         return new Looper();
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>  --
>>>>> 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.
>>>
>>
>>  --
> 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