F
freshharry
Fortgeschrittenes Mitglied
- 4
Hi
Ich bin derzeit dabei das IOIO Board v1 für Android in Betrieb zu nehmen und habe ein kleines Problem dabei. Ich habe das Anfängerbeispiel durchgemacht und das einfügen von helloioio und den Bibliotheken hat alles funktioniert ich kann es auch runterspielen aber ich kann die LED nicht ein und ausschalten. Teilweise leuchtet die orange LED einfach immer. Ich habe sowohl mit einen SE Xperia X8 als auch mit einen Galaxy II versucht aber es hat nicht funktioniert.
Mein Code ist der original Code nur mit einen TextView damit ich sehe wie weit er kommt. Manchmal kommt er bis Punkt 2 aber meistens steht nur 1 da. Hatte hier vielleicht jemand schon mal das selbe Problem? Würde mich über eine kleine Hilfestellung freuen.
mfg Harald
Ich bin derzeit dabei das IOIO Board v1 für Android in Betrieb zu nehmen und habe ein kleines Problem dabei. Ich habe das Anfängerbeispiel durchgemacht und das einfügen von helloioio und den Bibliotheken hat alles funktioniert ich kann es auch runterspielen aber ich kann die LED nicht ein und ausschalten. Teilweise leuchtet die orange LED einfach immer. Ich habe sowohl mit einen SE Xperia X8 als auch mit einen Galaxy II versucht aber es hat nicht funktioniert.
Mein Code ist der original Code nur mit einen TextView damit ich sehe wie weit er kommt. Manchmal kommt er bis Punkt 2 aber meistens steht nur 1 da. Hatte hier vielleicht jemand schon mal das selbe Problem? Würde mich über eine kleine Hilfestellung freuen.
mfg Harald
Code:
package ioio.examples.hello;
import ioio.lib.api.DigitalOutput;
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;
/**
* This is the main activity of the HelloIOIO example application.
*
* It displays a toggle button on the screen, which enables control of the
* on-board LED. This example shows a very simple usage of the IOIO, by using
* the {@link IOIOActivity} class. For a more advanced use case, see the
* HelloIOIOPower example.
*/
public class MainActivity extends IOIOActivity {
private ToggleButton button_;
private TextView text_;
/**
* Called when the activity is first created. Here we normally initialize
* our GUI.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button_ = (ToggleButton) findViewById(R.id.button);
text_ = (TextView) findViewById(R.id.textView1);
text_.setText("1");
}
/**
* This is the thread on which all the IOIO activity happens. It will be run
* every time the application is resumed and aborted when it is paused. The
* method setup() will be called right after a connection with the IOIO has
* been established (which might happen several times!). Then, loop() will
* be called repetitively until the IOIO gets disconnected.
*/
class Looper extends BaseIOIOLooper {
/** The on-board LED. */
private DigitalOutput led_;
/**
* Called every time a connection with IOIO has been established.
* Typically used to open pins.
*
* @throws ConnectionLostException
* When IOIO connection is lost.
*
* @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
*/
@Override
protected void setup() throws ConnectionLostException {
led_ = ioio_.openDigitalOutput(0, true);
text_.setText("2");
}
/**
* Called repetitively while the IOIO is connected.
*
* @throws ConnectionLostException
* When IOIO connection is lost.
*
* @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
*/
@Override
public void loop() throws ConnectionLostException {
led_.write(!button_.isChecked());
text_.setText("3");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}
/**
* A method to create our IOIO thread.
*
* @see ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
*/
@Override
protected IOIOLooper createIOIOLooper() {
return new Looper();
}
}