sensors.h File Reference
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
#include <cutils/native_handle.h>

Go to the source code of this file.

Data Structures

struct  sensors_vec_t
 
struct  uncalibrated_event_t
 
struct  meta_data_event
 
struct  heart_rate_event_t
 
struct  sensors_event_t
 
struct  sensors_module_t
 
struct  sensor_t
 
struct  sensors_poll_device_t
 
struct  sensors_poll_device_1
 

Macros

#define SENSORS_HEADER_VERSION   1
 
#define SENSORS_MODULE_API_VERSION_0_1   HARDWARE_MODULE_API_VERSION(0, 1)
 
#define SENSORS_DEVICE_API_VERSION_0_1   HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_0   HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_1   HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_2   HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_3   HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION)
 
#define SENSORS_HARDWARE_MODULE_ID   "sensors"
 
#define SENSORS_HARDWARE_POLL   "poll"
 
#define SENSORS_HANDLE_BASE   0
 
#define SENSORS_HANDLE_BITS   8
 
#define SENSORS_HANDLE_COUNT   (1<<SENSORS_HANDLE_BITS)
 
#define SENSOR_PERMISSION_BODY_SENSORS   "android.permission.BODY_SENSORS"
 
#define REPORTING_MODE_MASK   (0xE)
 
#define REPORTING_MODE_SHIFT   (1)
 
#define SENSOR_TYPE_DEVICE_PRIVATE_BASE   0x10000
 
#define SENSOR_TYPE_META_DATA   (0)
 
#define SENSOR_TYPE_ACCELEROMETER   (1)
 
#define SENSOR_STRING_TYPE_ACCELEROMETER   "android.sensor.accelerometer"
 
#define SENSOR_TYPE_GEOMAGNETIC_FIELD   (2)
 
#define SENSOR_TYPE_MAGNETIC_FIELD   SENSOR_TYPE_GEOMAGNETIC_FIELD
 
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD   "android.sensor.magnetic_field"
 
#define SENSOR_TYPE_ORIENTATION   (3)
 
#define SENSOR_STRING_TYPE_ORIENTATION   "android.sensor.orientation"
 
#define SENSOR_TYPE_GYROSCOPE   (4)
 
#define SENSOR_STRING_TYPE_GYROSCOPE   "android.sensor.gyroscope"
 
#define SENSOR_TYPE_LIGHT   (5)
 
#define SENSOR_STRING_TYPE_LIGHT   "android.sensor.light"
 
#define SENSOR_TYPE_PRESSURE   (6)
 
#define SENSOR_STRING_TYPE_PRESSURE   "android.sensor.pressure"
 
#define SENSOR_TYPE_TEMPERATURE   (7)
 
#define SENSOR_STRING_TYPE_TEMPERATURE   "android.sensor.temperature"
 
#define SENSOR_TYPE_PROXIMITY   (8)
 
#define SENSOR_STRING_TYPE_PROXIMITY   "android.sensor.proximity"
 
#define SENSOR_TYPE_GRAVITY   (9)
 
#define SENSOR_STRING_TYPE_GRAVITY   "android.sensor.gravity"
 
#define SENSOR_TYPE_LINEAR_ACCELERATION   (10)
 
#define SENSOR_STRING_TYPE_LINEAR_ACCELERATION   "android.sensor.linear_acceleration"
 
#define SENSOR_TYPE_ROTATION_VECTOR   (11)
 
#define SENSOR_STRING_TYPE_ROTATION_VECTOR   "android.sensor.rotation_vector"
 
#define SENSOR_TYPE_RELATIVE_HUMIDITY   (12)
 
#define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY   "android.sensor.relative_humidity"
 
#define SENSOR_TYPE_AMBIENT_TEMPERATURE   (13)
 
#define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE   "android.sensor.ambient_temperature"
 
#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED   (14)
 
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED   "android.sensor.magnetic_field_uncalibrated"
 
#define SENSOR_TYPE_GAME_ROTATION_VECTOR   (15)
 
#define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR   "android.sensor.game_rotation_vector"
 
#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED   (16)
 
#define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED   "android.sensor.gyroscope_uncalibrated"
 
#define SENSOR_TYPE_SIGNIFICANT_MOTION   (17)
 
#define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION   "android.sensor.significant_motion"
 
#define SENSOR_TYPE_STEP_DETECTOR   (18)
 
#define SENSOR_STRING_TYPE_STEP_DETECTOR   "android.sensor.step_detector"
 
#define SENSOR_TYPE_STEP_COUNTER   (19)
 
#define SENSOR_STRING_TYPE_STEP_COUNTER   "android.sensor.step_counter"
 
#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR   (20)
 
#define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR   "android.sensor.geomagnetic_rotation_vector"
 
#define SENSOR_TYPE_HEART_RATE   (21)
 
#define SENSOR_STRING_TYPE_HEART_RATE   "android.sensor.heart_rate"
 
#define SENSOR_TYPE_TILT_DETECTOR   (22)
 
#define SENSOR_STRING_TYPE_TILT_DETECTOR   "android.sensor.tilt_detector"
 
#define SENSOR_TYPE_WAKE_GESTURE   (23)
 
#define SENSOR_STRING_TYPE_WAKE_GESTURE   "android.sensor.wake_gesture"
 
#define SENSOR_TYPE_GLANCE_GESTURE   (24)
 
#define SENSOR_STRING_TYPE_GLANCE_GESTURE   "android.sensor.glance_gesture"
 
#define SENSOR_TYPE_PICK_UP_GESTURE   (25)
 
#define SENSOR_STRING_TYPE_PICK_UP_GESTURE   "android.sensor.pick_up_gesture"
 
#define GRAVITY_SUN   (275.0f)
 
#define GRAVITY_EARTH   (9.80665f)
 
#define MAGNETIC_FIELD_EARTH_MAX   (60.0f)
 
#define MAGNETIC_FIELD_EARTH_MIN   (30.0f)
 
#define SENSOR_STATUS_NO_CONTACT   -1
 
#define SENSOR_STATUS_UNRELIABLE   0
 
#define SENSOR_STATUS_ACCURACY_LOW   1
 
#define SENSOR_STATUS_ACCURACY_MEDIUM   2
 
#define SENSOR_STATUS_ACCURACY_HIGH   3
 

Typedefs

typedef struct meta_data_event meta_data_event_t
 
typedef struct sensors_event_t sensors_event_t
 
typedef sensors_event_t sensors_meta_data_event_t
 
typedef struct
sensors_poll_device_1 
sensors_poll_device_1_t
 

Enumerations

enum  { SENSORS_BATCH_DRY_RUN = 0x00000001, SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 }
 
enum  { META_DATA_FLUSH_COMPLETE = 1, META_DATA_VERSION }
 
enum  {
  SENSOR_FLAG_WAKE_UP = 1U << 0, SENSOR_FLAG_CONTINUOUS_MODE = 0, SENSOR_FLAG_ON_CHANGE_MODE = 0x2, SENSOR_FLAG_ONE_SHOT_MODE = 0x4,
  SENSOR_FLAG_SPECIAL_REPORTING_MODE = 0x6
}
 

Macro Definition Documentation

#define GRAVITY_EARTH   (9.80665f)

Definition at line 610 of file sensors.h.

#define GRAVITY_SUN   (275.0f)

Values returned by the accelerometer in various locations in the universe. all values are in SI units (m/s^2)

Definition at line 609 of file sensors.h.

#define MAGNETIC_FIELD_EARTH_MAX   (60.0f)

Maximum magnetic field on Earth's surface

Definition at line 613 of file sensors.h.

#define MAGNETIC_FIELD_EARTH_MIN   (30.0f)

Minimum magnetic field on Earth's surface

Definition at line 616 of file sensors.h.

#define REPORTING_MODE_MASK   (0xE)

Definition at line 123 of file sensors.h.

#define REPORTING_MODE_SHIFT   (1)

Definition at line 124 of file sensors.h.

#define SENSOR_PERMISSION_BODY_SENSORS   "android.permission.BODY_SENSORS"

Definition at line 93 of file sensors.h.

#define SENSOR_STATUS_ACCURACY_HIGH   3

Definition at line 625 of file sensors.h.

#define SENSOR_STATUS_ACCURACY_LOW   1

Definition at line 623 of file sensors.h.

#define SENSOR_STATUS_ACCURACY_MEDIUM   2

Definition at line 624 of file sensors.h.

#define SENSOR_STATUS_NO_CONTACT   -1

Possible values of the status field of sensor events.

Definition at line 621 of file sensors.h.

#define SENSOR_STATUS_UNRELIABLE   0

Definition at line 622 of file sensors.h.

#define SENSOR_STRING_TYPE_ACCELEROMETER   "android.sensor.accelerometer"

Definition at line 248 of file sensors.h.

#define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE   "android.sensor.ambient_temperature"

Definition at line 393 of file sensors.h.

#define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR   "android.sensor.game_rotation_vector"

Definition at line 419 of file sensors.h.

#define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR   "android.sensor.geomagnetic_rotation_vector"

Definition at line 490 of file sensors.h.

#define SENSOR_STRING_TYPE_GLANCE_GESTURE   "android.sensor.glance_gesture"

Definition at line 590 of file sensors.h.

#define SENSOR_STRING_TYPE_GRAVITY   "android.sensor.gravity"

Definition at line 343 of file sensors.h.

#define SENSOR_STRING_TYPE_GYROSCOPE   "android.sensor.gyroscope"

Definition at line 290 of file sensors.h.

#define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED   "android.sensor.gyroscope_uncalibrated"

Definition at line 432 of file sensors.h.

#define SENSOR_STRING_TYPE_HEART_RATE   "android.sensor.heart_rate"

Definition at line 514 of file sensors.h.

#define SENSOR_STRING_TYPE_LIGHT   "android.sensor.light"

Definition at line 301 of file sensors.h.

#define SENSOR_STRING_TYPE_LINEAR_ACCELERATION   "android.sensor.linear_acceleration"

Definition at line 356 of file sensors.h.

#define SENSOR_STRING_TYPE_MAGNETIC_FIELD   "android.sensor.magnetic_field"

Definition at line 262 of file sensors.h.

#define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED   "android.sensor.magnetic_field_uncalibrated"

Definition at line 406 of file sensors.h.

#define SENSOR_STRING_TYPE_ORIENTATION   "android.sensor.orientation"

Definition at line 277 of file sensors.h.

#define SENSOR_STRING_TYPE_PICK_UP_GESTURE   "android.sensor.pick_up_gesture"

Definition at line 603 of file sensors.h.

#define SENSOR_STRING_TYPE_PRESSURE   "android.sensor.pressure"

Definition at line 313 of file sensors.h.

#define SENSOR_STRING_TYPE_PROXIMITY   "android.sensor.proximity"

Definition at line 330 of file sensors.h.

#define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY   "android.sensor.relative_humidity"

Definition at line 382 of file sensors.h.

#define SENSOR_STRING_TYPE_ROTATION_VECTOR   "android.sensor.rotation_vector"

Definition at line 370 of file sensors.h.

#define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION   "android.sensor.significant_motion"

Definition at line 447 of file sensors.h.

#define SENSOR_STRING_TYPE_STEP_COUNTER   "android.sensor.step_counter"

Definition at line 477 of file sensors.h.

#define SENSOR_STRING_TYPE_STEP_DETECTOR   "android.sensor.step_detector"

Definition at line 461 of file sensors.h.

#define SENSOR_STRING_TYPE_TEMPERATURE   "android.sensor.temperature"

Definition at line 317 of file sensors.h.

#define SENSOR_STRING_TYPE_TILT_DETECTOR   "android.sensor.tilt_detector"

Definition at line 542 of file sensors.h.

#define SENSOR_STRING_TYPE_WAKE_GESTURE   "android.sensor.wake_gesture"

Definition at line 564 of file sensors.h.

#define SENSOR_TYPE_ACCELEROMETER   (1)

Definition at line 247 of file sensors.h.

#define SENSOR_TYPE_AMBIENT_TEMPERATURE   (13)

Definition at line 392 of file sensors.h.

#define SENSOR_TYPE_DEVICE_PRIVATE_BASE   0x10000

Definition at line 177 of file sensors.h.

#define SENSOR_TYPE_GAME_ROTATION_VECTOR   (15)

Definition at line 418 of file sensors.h.

#define SENSOR_TYPE_GEOMAGNETIC_FIELD   (2)

Definition at line 260 of file sensors.h.

#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR   (20)

Definition at line 489 of file sensors.h.

#define SENSOR_TYPE_GLANCE_GESTURE   (24)

Definition at line 589 of file sensors.h.

#define SENSOR_TYPE_GRAVITY   (9)

Definition at line 342 of file sensors.h.

#define SENSOR_TYPE_GYROSCOPE   (4)

Definition at line 289 of file sensors.h.

#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED   (16)

Definition at line 431 of file sensors.h.

#define SENSOR_TYPE_HEART_RATE   (21)

Definition at line 513 of file sensors.h.

#define SENSOR_TYPE_LIGHT   (5)

Definition at line 300 of file sensors.h.

#define SENSOR_TYPE_LINEAR_ACCELERATION   (10)

Definition at line 355 of file sensors.h.

#define SENSOR_TYPE_MAGNETIC_FIELD   SENSOR_TYPE_GEOMAGNETIC_FIELD

Definition at line 261 of file sensors.h.

#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED   (14)

Definition at line 405 of file sensors.h.

#define SENSOR_TYPE_META_DATA   (0)

Definition at line 210 of file sensors.h.

#define SENSOR_TYPE_ORIENTATION   (3)

Definition at line 276 of file sensors.h.

#define SENSOR_TYPE_PICK_UP_GESTURE   (25)

SENSOR_TYPE_PICK_UP_GESTURE reporting-mode: one-shot

A sensor of this type triggers when the device is picked up regardless of wherever is was before (desk, pocket, bag). The only allowed return value is 1.0. This sensor de-activates itself immediately after it triggers.

Implement only the wake-up version of this sensor.

Definition at line 602 of file sensors.h.

#define SENSOR_TYPE_PRESSURE   (6)

Definition at line 312 of file sensors.h.

#define SENSOR_TYPE_PROXIMITY   (8)

Definition at line 329 of file sensors.h.

#define SENSOR_TYPE_RELATIVE_HUMIDITY   (12)

Definition at line 381 of file sensors.h.

#define SENSOR_TYPE_ROTATION_VECTOR   (11)

Definition at line 369 of file sensors.h.

#define SENSOR_TYPE_SIGNIFICANT_MOTION   (17)

Definition at line 446 of file sensors.h.

#define SENSOR_TYPE_STEP_COUNTER   (19)

Definition at line 476 of file sensors.h.

#define SENSOR_TYPE_STEP_DETECTOR   (18)

Definition at line 460 of file sensors.h.

#define SENSOR_TYPE_TEMPERATURE   (7)

Definition at line 316 of file sensors.h.

#define SENSOR_TYPE_TILT_DETECTOR   (22)

Definition at line 541 of file sensors.h.

#define SENSOR_TYPE_WAKE_GESTURE   (23)

Definition at line 563 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_0_1   HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION)

Definition at line 33 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_0   HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION)

Definition at line 34 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_1   HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION)

Definition at line 35 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_2   HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION)

Definition at line 36 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_3   HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION)

Definition at line 37 of file sensors.h.

#define SENSORS_HANDLE_BASE   0

Handles must be higher than SENSORS_HANDLE_BASE and must be unique. A Handle identifies a given sensors. The handle is used to activate and/or deactivate sensors. In this version of the API there can only be 256 handles.

Definition at line 61 of file sensors.h.

#define SENSORS_HANDLE_BITS   8

Definition at line 62 of file sensors.h.

#define SENSORS_HANDLE_COUNT   (1<<SENSORS_HANDLE_BITS)

Definition at line 63 of file sensors.h.

#define SENSORS_HARDWARE_MODULE_ID   "sensors"

Please see the Sensors section of source.android.com for an introduction to and detailed descriptions of Android sensor types: http://source.android.com/devices/sensors/index.html The id of this module

Definition at line 48 of file sensors.h.

#define SENSORS_HARDWARE_POLL   "poll"

Name of the sensors device to open

Definition at line 53 of file sensors.h.

#define SENSORS_HEADER_VERSION   1

Definition at line 31 of file sensors.h.

#define SENSORS_MODULE_API_VERSION_0_1   HARDWARE_MODULE_API_VERSION(0, 1)

Definition at line 32 of file sensors.h.

Typedef Documentation

Meta data event data

Union of the various types of sensor data that can be returned.

Definition at line 775 of file sensors.h.

Enumeration Type Documentation

anonymous enum
Enumerator
SENSORS_BATCH_DRY_RUN 
SENSORS_BATCH_WAKE_UPON_FIFO_FULL 

Definition at line 74 of file sensors.h.

anonymous enum
Enumerator
META_DATA_FLUSH_COMPLETE 
META_DATA_VERSION 

Definition at line 82 of file sensors.h.

anonymous enum
Enumerator
SENSOR_FLAG_WAKE_UP 
SENSOR_FLAG_CONTINUOUS_MODE 
SENSOR_FLAG_ON_CHANGE_MODE 
SENSOR_FLAG_ONE_SHOT_MODE 
SENSOR_FLAG_SPECIAL_REPORTING_MODE 

Definition at line 99 of file sensors.h.