The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.hardware; |
| 18 | |
| 19 | /** |
| 20 | * Used for receiving notifications from the SensorManager when |
| 21 | * sensor values have changed. |
| 22 | * |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 23 | * @deprecated Use |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | * {@link android.hardware.SensorEventListener SensorEventListener} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | */ |
| 26 | @Deprecated |
| 27 | public interface SensorListener { |
| 28 | |
| 29 | /** |
| 30 | * <p>Called when sensor values have changed. |
| 31 | * The length and contents of the values array vary |
| 32 | * depending on which sensor is being monitored. |
| 33 | * See {@link android.hardware.SensorManager SensorManager} |
| 34 | * for details on possible sensor types. |
| 35 | * |
| 36 | * <p><u>Definition of the coordinate system used below.</u><p> |
| 37 | * <p>The X axis refers to the screen's horizontal axis |
| 38 | * (the small edge in portrait mode, the long edge in landscape mode) and |
| 39 | * points to the right. |
| 40 | * <p>The Y axis refers to the screen's vertical axis and points towards |
| 41 | * the top of the screen (the origin is in the lower-left corner). |
| 42 | * <p>The Z axis points toward the sky when the device is lying on its back |
| 43 | * on a table. |
| 44 | * <p> <b>IMPORTANT NOTE:</b> The axis <b><u>are swapped</u></b> when the |
| 45 | * device's screen orientation changes. To access the unswapped values, |
| 46 | * use indices 3, 4 and 5 in values[]. |
| 47 | * |
| 48 | * <p>{@link android.hardware.SensorManager#SENSOR_ORIENTATION SENSOR_ORIENTATION}, |
| 49 | * {@link android.hardware.SensorManager#SENSOR_ORIENTATION_RAW SENSOR_ORIENTATION_RAW}:<p> |
| 50 | * All values are angles in degrees. |
| 51 | * |
| 52 | * <p>values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). |
| 53 | * 0 = North, 90 = East, 180 = South, 270 = West |
| 54 | * |
| 55 | * <p>values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive |
| 56 | * values when the z-axis moves toward the y-axis. |
| 57 | * |
| 58 | * <p>values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values |
| 59 | * when the z-axis moves toward the x-axis. |
| 60 | * |
| 61 | * <p>Note that this definition of yaw, pitch and roll is different from the |
| 62 | * traditional definition used in aviation where the X axis is along the long |
| 63 | * side of the plane (tail to nose). |
| 64 | * |
| 65 | * <p>{@link android.hardware.SensorManager#SENSOR_ACCELEROMETER SENSOR_ACCELEROMETER}:<p> |
| 66 | * All values are in SI units (m/s^2) and measure contact forces. |
| 67 | * |
| 68 | * <p>values[0]: force applied by the device on the x-axis |
| 69 | * <p>values[1]: force applied by the device on the y-axis |
| 70 | * <p>values[2]: force applied by the device on the z-axis |
| 71 | * |
| 72 | * <p><u>Examples</u>: |
| 73 | * <li>When the device is pushed on its left side toward the right, the |
| 74 | * x acceleration value is negative (the device applies a reaction force |
| 75 | * to the push toward the left)</li> |
| 76 | * |
| 77 | * <li>When the device lies flat on a table, the acceleration value is |
| 78 | * {@link android.hardware.SensorManager#STANDARD_GRAVITY -STANDARD_GRAVITY}, |
| 79 | * which correspond to the force the device applies on the table in reaction |
| 80 | * to gravity.</li> |
| 81 | * |
| 82 | * <p>{@link android.hardware.SensorManager#SENSOR_MAGNETIC_FIELD SENSOR_MAGNETIC_FIELD}:<p> |
| 83 | * All values are in micro-Tesla (uT) and measure the ambient magnetic |
| 84 | * field in the X, Y and -Z axis. |
| 85 | * <p><b><u>Note:</u></b> the magnetic field's Z axis is inverted. |
| 86 | * |
| 87 | * @param sensor The ID of the sensor being monitored |
| 88 | * @param values The new values for the sensor. |
| 89 | */ |
| 90 | public void onSensorChanged(int sensor, float[] values); |
| 91 | |
| 92 | /** |
| 93 | * Called when the accuracy of a sensor has changed. |
| 94 | * See {@link android.hardware.SensorManager SensorManager} |
| 95 | * for details. |
| 96 | * |
| 97 | * @param sensor The ID of the sensor being monitored |
| 98 | * @param accuracy The new accuracy of this sensor. |
| 99 | */ |
| 100 | public void onAccuracyChanged(int sensor, int accuracy); |
| 101 | } |