Android Open Source - noxdroidandroidapp I O I O Activity






From Project

Back to project page noxdroidandroidapp.

License

The source code is released under:

MIT License

If you think the Android project noxdroidandroidapp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dk.itu.noxdroid.experiments;
//from   w  w w .  ja  v a 2s  . c om

import ioio.lib.api.AnalogInput;
import ioio.lib.api.DigitalOutput;
import ioio.lib.api.DigitalOutput.Spec;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.util.AbstractIOIOActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.ToggleButton;
import dk.itu.noxdroid.R;

public class IOIOActivity extends AbstractIOIOActivity {
  private TextView textView_;
  private TextView debug_;
  private ToggleButton toggleButton_;
  private String TAG;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    TAG = getString(R.string.LOGCAT_TAG, getString(R.string.app_name), this
        .getClass().getSimpleName());
    
    setContentView(R.layout.ioio);

    textView_ = (TextView) findViewById(R.id.textView1);
    toggleButton_ = (ToggleButton) findViewById(R.id.toggleButton1);
    debug_ = (TextView) findViewById(R.id.textView2);
    addToDebug("OnCreate");
  }

  class IOIOThread extends AbstractIOIOActivity.IOIOThread {
    private AnalogInput input_;

    private DigitalOutput led_;
    private int pinLed = 9;
    private int pinIn = 11;

    @Override
    public void setup() throws ConnectionLostException {
      addToDebug("Setup()");
      try {
        // input_ = ioio_.openAnalogInput(pinIn);
        led_ = ioio_.openDigitalOutput(pinLed, Spec.Mode.NORMAL, true);

      } catch (ConnectionLostException e) {

        throw e;
      }
    }

    @Override
    public void loop() throws ConnectionLostException {
      addToDebug("Loop");
      try {
//        final float reading = input_.read();
//        setText(Float.toString(reading));
        led_.write(!toggleButton_.isChecked());
        sleep(1000);
      } catch (InterruptedException e) {
        ioio_.disconnect();
      } catch (ConnectionLostException e) {
        throw e;
      }
    }
  }

  @Override
  protected AbstractIOIOActivity.IOIOThread createIOIOThread() {
    addToDebug("Return new IOIOThread");
    return new IOIOThread();
  }

  private void addToDebug(final String str) {
    runOnUiThread(new Runnable() {
      @Override
      public void run() {
        debug_.append(str + "\n");
      };
    });
    
  }

  private void setText(final String str) {
    runOnUiThread(new Runnable() {
      @Override
      public void run() {
        debug_.append(str + "\n");
        textView_.setText(str);
      }
    });
  }
}




Java Source Code List

dk.itu.noxdroid.NoxDroidActivity.java
dk.itu.noxdroid.NoxDroidApp.java
dk.itu.noxdroid.NoxDroidMainActivity.java
dk.itu.noxdroid.cloudservice.NoxDroidAppEngineUtils.java
dk.itu.noxdroid.database.NoxDroidDbAdapter.java
dk.itu.noxdroid.experiments.ConnectivityTest.java
dk.itu.noxdroid.experiments.DbAdapter.java
dk.itu.noxdroid.experiments.IOIOActivity.java
dk.itu.noxdroid.experiments.IOIOSensorActivity.java
dk.itu.noxdroid.experiments.NoxDroidGPSActivity.java
dk.itu.noxdroid.geocommons.api.DataSet.java
dk.itu.noxdroid.ioio.IOIOConnectedTestThread.java
dk.itu.noxdroid.ioio.IOIOEventListener.java
dk.itu.noxdroid.ioio.NoxDroidIOIOThread.java
dk.itu.noxdroid.location.GPSLocationService.java
dk.itu.noxdroid.location.SkyHookLocationService.java
dk.itu.noxdroid.model.LocationSensor.java
dk.itu.noxdroid.model.Location.java
dk.itu.noxdroid.model.NoxDroid.java
dk.itu.noxdroid.model.NoxSensor.java
dk.itu.noxdroid.model.Nox.java
dk.itu.noxdroid.model.Sensor.java
dk.itu.noxdroid.model.Track.java
dk.itu.noxdroid.service.NoxDroidService.java
dk.itu.noxdroid.setup.PreferencesActivity.java
dk.itu.noxdroid.tracks.TracksListActivity.java
dk.itu.noxdroid.util.GPSUtil.java
dk.itu.noxdroid.util.Line.java
dk.itu.noxdroid.util.SensorDataUtil.java