Structure to store information about a sensor event, which is obtained during a read.
Synopsis:
typedef struct {
size_t size ;
sensor_type_e type ;
uint32_t flags ;
sensor_accuracy_e accuracy ;
uint64_t timestamp ;
union {
struct {
struct {
float x, y, z;
} dsp, raw;
union {
struct {
float temperature;
} gyro;
};
} motion;
float raw_data [18];
float rotation_matrix [3*3];
struct {
int screen;
char face [64];
} orientation;
struct {
float azimuth;
float pitch;
float roll;
} apr;
struct {
float distance;
float normalized;
} proximity_s;
struct {
float pressure;
float temperature;
} pressure_s;
struct {
float altitude ;
} altitude_s;
struct {
float illuminance;
} light_s;
struct {
int face_detect;
} face_detect_s;
struct {
float temperature;
} temperature_s;
struct {
int holstered;
} holster_s;
struct {
float azimuth;
int is_face_down;
} compass_s;
/** The following entries are deprecated; use the structures above, instead: **/
float proximity;
float pressure;
float altitude;
float illuminance;
int face_detect;
float temperature;
struct {
float x,y,x;
struct {
float x,y,z;
} raw;
} axis_s;
};
}sensor_event_t;
Data:
-
size_t size
- The size of this structure, which you can use to determine the version of the library you're using.
-
sensor_type_e type
- The sensor type, used to index into appropriate payload.
-
uint32_t flags
- Flags.
-
sensor_accuracy_e accuracy
- The accuracy associated with this sample.
-
uint64_t timestamp
- Time stamp of data acquisition, value in nanoseconds.
-
float raw_data
- Misc bucket for data payload.
-
float rotation_matrix
- Rotation Matrix.
-
struct motion
- Used by motion sensors such as Accelerometer, Magnetometer, Gyroscope, Linear
Acceleration and Gravity. The units of measure for the x,
y and z values are as follows:
- Accelerometer, Linear Acceleration, Gravity: m/s/s
(meters/second/second)
- Magnetometer: uT (micro Tesla)
- Gyroscope: r/s (radians/second)
-
float x
- x-value of the sensor.
-
float y
- y-value of the sensor.
-
float z
- z-value of the sensor.
-
dsp
- Signal-processed/calibrated values.
-
raw
- Raw sensor values.
-
float gyro.temperature
- The temperature of the gyroscope sensor (in degrees Celsius).
-
struct orientation
- Used by the orientation sensor.
-
int screen
- Screen rotation in degrees: 0, 90, 180 or 270.
-
char face
- String-based representation of device face. This is
one of:
- LEFT_UP
- RIGHT_UP
- TOP_UP
- BOTTOM_UP
- FACE_UP
- FACE_DOWN
-
struct apr
- Used by the azimuth/pitch/roll sensor.
-
float azimuth
- 0 to 359 degrees.
-
Azimuth from 0 -> 359 degrees from magnetic north.
-
float pitch
- -180 to 180 degrees.
-
float roll
- -90 to 90 degrees.
-
struct proximity_s
- Used by the proximity sensor.
-
float distance
- range_min -> range_max, discrete steps of distance or actual value in cm.
-
float normalized
- 0.0 -> 1.0 (close -> far), normalized unit-less signal from raw
sensor.
-
struct pressure_s
- Used by the pressure sensor.
-
float pressure
- Pressure in pascals (Pa).
-
float temperature
- Temperature in degrees Celsius.
-
struct altitude_s
- Used by altitude sensor.
-
float altitude
- Altitude (in meters) relative to mean sea level.
-
struct light_s
- Used by the light sensor.
-
float illuminance
- Illuminance in lux.
-
struct face_detect_s
- Used by the face-detection sensor.
-
int face_detect
- 1 if a face is detected, 0 otherwise.
-
struct temperature_s
- Used by the temperature sensor.
-
float temperature
- Temperature in degrees Celsius.
-
struct holster_s
- Used by the holster sensor.
-
int holstered
- Holster status. 0 for not holstered, 1 for holstered.
-
struct compass_s
- Used by the compass sensor.
-
int is_face_down
- 1 if the device's face is down and compass heading is flipped, 0 otherwise.
-
float azimuth
- 0 to 359 degrees.
-
Azimuth from 0 -> 359 degrees from magnetic north.
-
Deprecated variables
- Use the structures above instead of the following deprecated items:
-
float proximity
- Use proximity_s.distance instead.
-
float pressure
- Use pressure_s.pressure instead.
-
float altitude
- Use altitude_s.altitude instead.
-
float illuminance
- Use light_s.illuminance instead.
-
int face_detect
- Use face_detect_s.face_detect instead.
-
float temperature
- Use temperature_s.temperature instead.
-
axis_s: float x,y,z; axis.raw:
float x,y,z
- Use motion instead.
Library:
None.
Description:
Note that only one section of the union is used for any event. For example, when a
SENSOR_TYPE_COMPASS event occurs, the
compass_s is populated with the event data.