Example usage for android.hardware SensorManager DATA_Y

List of usage examples for android.hardware SensorManager DATA_Y

Introduction

In this page you can find the example usage for android.hardware SensorManager DATA_Y.

Prototype

int DATA_Y

To view the source code for android.hardware SensorManager DATA_Y.

Click Source Link

Document

Index of the Y value in the array returned by android.hardware.SensorListener#onSensorChanged

Usage

From source file:Main.java

public static boolean move(float[] values, float[] preAccelerometerValues) {
    float difx = Math.abs(values[SensorManager.DATA_X]);
    float dify = Math.abs(values[SensorManager.DATA_Y]);
    float difz = Math.abs(values[SensorManager.DATA_Z]);
    Log.e("log.e val = ", " " + difx + " " + dify + " " + difz);

    float difx1 = Math.abs(preAccelerometerValues[SensorManager.DATA_X]);
    float dify1 = Math.abs(preAccelerometerValues[SensorManager.DATA_Y]);
    float difz1 = Math.abs(preAccelerometerValues[SensorManager.DATA_Z]);
    Log.e("log.e pre = ", " " + difx1 + " " + dify1 + " " + difz1);

    float difx2 = Math.abs(values[SensorManager.DATA_X] - preAccelerometerValues[SensorManager.DATA_X]);
    float dify2 = Math.abs(values[SensorManager.DATA_Y] - preAccelerometerValues[SensorManager.DATA_Y]);
    float difz2 = Math.abs(values[SensorManager.DATA_Z] - preAccelerometerValues[SensorManager.DATA_Z]);
    Log.e("log.e  dif = ", " " + difx2 + " " + dify2 + " " + difz2);

    if (checkMove(values[SensorManager.DATA_X], preAccelerometerValues[SensorManager.DATA_X])
            || checkMove(values[SensorManager.DATA_Y], preAccelerometerValues[SensorManager.DATA_Y])
            || checkMove(values[SensorManager.DATA_Z], preAccelerometerValues[SensorManager.DATA_Z])) {
        return true;
    }/*from   w  ww.  j a  v a2  s  .  co m*/
    return false;
}

From source file:edu.cens.loci.sensors.AccelerometerHandler.java

private synchronized void onSensorChangedLocked(SensorEvent event) {

    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

        mFlag = true;//w w  w  .  j a va  2  s  .c o  m

        if (mIsOn)
            mMagArr.addMagnitude(event.values[SensorManager.DATA_X], event.values[SensorManager.DATA_Y],
                    event.values[SensorManager.DATA_Z], event.accuracy);

        //mXArr.add(event.values[SensorManager.DATA_X]);
        //mYArr.add(event.values[SensorManager.DATA_Y]);
        //mZArr.add(event.values[SensorManager.DATA_Z]);
    }
}