You are not allowed to call setText() from the IOIO thread. See how
IOIOSimpleApp handles this.
On Mar 5, 2014 11:04 PM, "ZackD" <[email protected]> wrote:
> Hello all,
>
> HelloIOIO was working on a Verizon Galaxy S, using the App-IOIO0324
> library (I'm on a V1 board marked 4-6-11 on the back...I'm assuming this is
> the production date).
> After adding a command to read() Analog pin 40, it no longer appears to
> connect to the board - or so I think, as the LED does not toggle and no
> setText() statements within loop() work.
> This is via USB by the way, so debug is limited until I can root this and
> mange to setup ADB/DDMS over WiFi...which is a task to do over a university
> network!
>
> Any idea why this might be happening? Any help is greatly appreciated!
>
> -------------------------------------
>
> MainActivity:
> package ioio.examples.hello;
>
> import ioio.lib.api.AnalogInput;
> 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.CompoundButton;
> import android.widget.CompoundButton.OnCheckedChangeListener;
> import android.widget.TextView;
> import android.widget.ToggleButton;
>
> public class MainActivity extends IOIOActivity {
> private ToggleButton button_;
> private TextView volts_;
> private Float f = 0.0f;
>
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> volts_ = (TextView) findViewById(R.id.voltVT);
> button_ = (ToggleButton) findViewById(R.id.button);
> button_.setOnCheckedChangeListener(new OnCheckedChangeListener() {
>
> public void onCheckedChanged(CompoundButton buttonView, boolean
> isChecked) {
> //just in case you want to do anything when you toggle it
> }
> });
> }
>
> class Looper extends BaseIOIOLooper {
> /** The on-board LED. */
> private DigitalOutput led_;
> private AnalogInput input_;
>
> @Override
> protected void setup() throws ConnectionLostException,
> InterruptedException {
> led_ = ioio_.openDigitalOutput(0, true);
> input_ = ioio_.openAnalogInput(40);
> }
>
> @Override
> public void loop(){
> if(button_.isChecked()){
> try {
> f = input_.read();
> volts_.setText(Float.toString(f));
> led_.write(!button_.isChecked());
> } catch (InterruptedException e) {
> e.printStackTrace();
> } catch (ConnectionLostException e) {
> e.printStackTrace();
> }
> }
> try {
> Thread.sleep(100);
> } catch (InterruptedException e) {
> }
> }
> }
>
> @Override
> 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/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.