Android Open Source - daisy_main C M Sensors






From Project

Back to project page daisy_main.

License

The source code is released under:

GNU General Public License

If you think the Android project daisy_main 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 de.uvwxy.daisy.nodemap.guicontent;
// ww  w . j a  v a2s.c o  m
import android.content.Context;
import de.uvwxy.sensors.AccelerometerReader;
import de.uvwxy.sensors.BarometerReader;
import de.uvwxy.sensors.CompassReader;
import de.uvwxy.sensors.SensorReader.SensorResultCallback;

public class CMSensors implements IDestroy {
  CompassReader compassReader = null;
  BarometerReader barometerReader = null;
  AccelerometerReader accelReader = null;

  @SuppressWarnings("unused")
  private Context mCtx;

  private float[] compassData;
  private float[] accelData;
  private float[] barodata;

  private SensorResultCallback cbCompass = new SensorResultCallback() {

    @Override
    public void result(float[] f) {
      compassData = f.clone();
    }
  };

  private SensorResultCallback cbAccel = new SensorResultCallback() {

    @Override
    public void result(float[] f) {
      accelData = f.clone();
    }
  };

  private SensorResultCallback cbBaro = new SensorResultCallback() {

    @Override
    public void result(float[] f) {
      barodata = f.clone();
    }
  };

  public CMSensors(Context ctx) {
    this.mCtx = ctx;
    compassReader = new CompassReader(CM.CTX, -1, cbCompass);
    compassReader.startReading();
    accelReader = new AccelerometerReader(CM.CTX, -1, cbAccel);
    accelReader.startReading();
    barometerReader = new BarometerReader(CM.CTX, -1, cbBaro);
    barometerReader.startReading();
  }

  public float[] getLastBarometerReading() {
    return barodata;
  }

  public float[] getLastAccelerometerReading() {
    return accelData;
  }

  public float[] getLastCompassReading() {
    return compassData;
  }

  @Override
  public void destroy() {
    compassReader.stopReading();
    barometerReader.stopReading();
    accelReader.stopReading();
  }
}




Java Source Code List

de.uvwxy.daisy.nodemap.gui.ActivityAnnotation.java
de.uvwxy.daisy.nodemap.gui.ActivityNodeDetails.java
de.uvwxy.daisy.nodemap.gui.DetailActivity.java
de.uvwxy.daisy.nodemap.gui.DetailFragment.java
de.uvwxy.daisy.nodemap.gui.MainListActivity.java
de.uvwxy.daisy.nodemap.gui.MainListFragment.java
de.uvwxy.daisy.nodemap.guicontent.CMARView.java
de.uvwxy.daisy.nodemap.guicontent.CMBalloon.java
de.uvwxy.daisy.nodemap.guicontent.CMLocation.java
de.uvwxy.daisy.nodemap.guicontent.CMLogs.java
de.uvwxy.daisy.nodemap.guicontent.CMMap.java
de.uvwxy.daisy.nodemap.guicontent.CMSensors.java
de.uvwxy.daisy.nodemap.guicontent.CMXBee.java
de.uvwxy.daisy.nodemap.guicontent.CM.java
de.uvwxy.daisy.nodemap.guicontent.IDestroy.java
de.uvwxy.daisy.nodemap.guiviews.CVARView.java
de.uvwxy.daisy.nodemap.guiviews.CVBalloonClient.java
de.uvwxy.daisy.nodemap.guiviews.CVBalloon.java
de.uvwxy.daisy.nodemap.guiviews.CVChat.java
de.uvwxy.daisy.nodemap.guiviews.CVDeploymentData.java
de.uvwxy.daisy.nodemap.guiviews.CVDeployment.java
de.uvwxy.daisy.nodemap.guiviews.CVLogs.java
de.uvwxy.daisy.nodemap.guiviews.CVMap.java
de.uvwxy.daisy.nodemap.guiviews.CVMenuItem.java
de.uvwxy.daisy.nodemap.guiviews.CVParticipantScan.java
de.uvwxy.daisy.nodemap.guiviews.CVXBee.java
de.uvwxy.daisy.nodemap.guiviews.CV.java
de.uvwxy.daisy.nodemap.listobjects.APIMessageArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.CVArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.ChatMessageArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.LogMessageArrayAdapter.java
de.uvwxy.daisy.nodemap.listobjects.SampleGridViewAdapter.java