Can help me see on my code ? The led just can't light on after i toggled my
button.
**********************************************************************************************************
package ioio.examples.simple;

import ioio.lib.api.DigitalOutput;

import ioio.lib.api.IOIO;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import ioio.lib.api.Uart;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.util.BaseIOIOLooper;
import ioio.lib.util.IOIOLooper;
import ioio.lib.util.android.IOIOActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.ToggleButton;

public class IOIOSimpleApp extends IOIOActivity {
private TextView textView_;
private ToggleButton toggleButton_;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView_ = (TextView) findViewById(R.id.TextView);
toggleButton_ = (ToggleButton) findViewById(R.id.ToggleButton);

enableUi(false);
}

class Looper extends BaseIOIOLooper {
private Uart input_;
private DigitalOutput led_;

@Override
public void setup() throws ConnectionLostException {
led_ = ioio_.openDigitalOutput(IOIO.LED_PIN, true);
input_ = ioio_.openUart(6, 7, 9600, Uart.Parity.NONE, Uart.StopBits.ONE);
enableUi(true);
}

@Override
public void loop() throws ConnectionLostException, InterruptedException {
InputStream in  = input_.getInputStream();
String reading = convertStreamToString(in);
setText(reading);
led_.write(!toggleButton_.isChecked());
Thread.sleep(10);
}

@Override
public void disconnected() {
enableUi(false);
}
}

@Override
protected IOIOLooper createIOIOLooper() {
return new Looper();
}

private void enableUi(final boolean enable) {
runOnUiThread(new Runnable() {
@Override
public void run() {
toggleButton_.setEnabled(enable);
}
});
}

private String convertStreamToString(InputStream reading){
 BufferedReader rd=new BufferedReader(new InputStreamReader(reading),4096);
String line;
StringBuilder sb=new StringBuilder();
try {
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
}catch (IOException e) {
e.printStackTrace();
}
String contentOfMyInputStream = sb.toString();
return contentOfMyInputStream;
}
private void setText (final String str) {
runOnUiThread(new Runnable() {
@Override
public void run() {
textView_.setText(str);
}
});
}
}


On Tue, Dec 17, 2013 at 9:15 AM, Ytai Ben-Tsvi <[email protected]> wrote:

> A good place to start is to try the prebuilt HelloIOIO.apk. This will tell
> us whether this is a problem with your app / build environment or a problem
> with the IOIO / Android comms.
>
>
> On Mon, Dec 16, 2013 at 9:03 AM, Al B <[email protected]> wrote:
>
>> If you are using eclipse, then try to trace the problem with the debugger
>> and report back here.
>>
>>
>>  --
>> 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/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "ioio-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ioio-users/wTlJJcG6LS8/unsubscribe.
> To unsubscribe from this group and all its topics, 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to