#define SENSORS_MAGFIELD_EARTH_MAX (60.0F) /**< Maximum magnetic field on Earth's surface */
#define SENSORS_MAGFIELD_EARTH_MIN (30.0F) /**< Minimum magnetic field on Earth's surface */
#define SENSORS_PRESSURE_SEALEVELHPA (1013.25F) /**< Average sea level pressure is 1013.25 hPa */
#define SENSORS_DPS_TO_RADS (0.017453293F) /**< Degrees/s to rad/s multiplier */
#define SENSORS_GAUSS_TO_MICROTESLA (100) /**< Gauss to micro-Tesla multiplier */
/** Sensor types */
typedefenum
{
SENSOR_TYPE_ACCELEROMETER=(1),/**< Gravity + linear acceleration */
SENSOR_TYPE_MAGNETIC_FIELD=(2),
SENSOR_TYPE_ORIENTATION=(3),
SENSOR_TYPE_GYROSCOPE=(4),
SENSOR_TYPE_LIGHT=(5),
SENSOR_TYPE_PRESSURE=(6),
SENSOR_TYPE_PROXIMITY=(8),
SENSOR_TYPE_GRAVITY=(9),
SENSOR_TYPE_LINEAR_ACCELERATION=(10),/**< Acceleration not including gravity */
SENSOR_TYPE_ROTATION_VECTOR=(11),
SENSOR_TYPE_RELATIVE_HUMIDITY=(12),
SENSOR_TYPE_AMBIENT_TEMPERATURE=(13),
SENSOR_TYPE_VOLTAGE=(15),
SENSOR_TYPE_CURRENT=(16),
SENSOR_TYPE_COLOR=(17)
}sensors_type_t;
/** struct sensors_vec_s is used to return a vector in a common format. */
typedefstruct{
union{
floatv[3];
struct{
floatx;
floaty;
floatz;
};
/* Orientation sensors */
struct{
floatroll;/**< Rotation around the longitudinal axis (the plane body, 'X axis'). Roll is positive and increasing when moving downward. -90<39><=roll<=90<39> */
floatpitch;/**< Rotation around the lateral axis (the wing span, 'Y axis'). Pitch is positive and increasing when moving upwards. -180<38><=pitch<=180<38>) */
floatheading;/**< Angle between the longitudinal axis (the plane body) and magnetic north, measured clockwise when viewing from the top of the device. 0-359<35> */
};
};
int8_tstatus;
uint8_treserved[3];
}sensors_vec_t;
/** struct sensors_color_s is used to return color data in a common format. */
typedefstruct{
union{
floatc[3];
/* RGB color space */
struct{
floatr;/**< Red component */
floatg;/**< Green component */
floatb;/**< Blue component */
};
};
uint32_trgba;/**< 24-bit RGBA value */
}sensors_color_t;
/* Sensor event (36 bytes) */
/** struct sensor_event_s is used to provide a single sensor event in a common format. */
typedefstruct
{
int32_tversion;/**< must be sizeof(struct sensors_event_t) */
int32_tsensor_id;/**< unique sensor identifier */
int32_ttype;/**< sensor type */
int32_treserved0;/**< reserved */
int32_ttimestamp;/**< time is in milliseconds */
union
{
floatdata[4];
sensors_vec_tacceleration;/**< acceleration values are in meter per second per second (m/s^2) */
sensors_vec_tmagnetic;/**< magnetic vector values are in micro-Tesla (uT) */
sensors_vec_torientation;/**< orientation values are in degrees */
sensors_vec_tgyro;/**< gyroscope values are in rad/s */
floattemperature;/**< temperature is in degrees centigrade (Celsius) */
floatdistance;/**< distance in centimeters */
floatlight;/**< light in SI lux units */
floatpressure;/**< pressure in hectopascal (hPa) */
floatrelative_humidity;/**< relative humidity in percent */
floatcurrent;/**< current in milliamps (mA) */
floatvoltage;/**< voltage in volts (V) */
sensors_color_tcolor;/**< color in RGB component values */
};
}sensors_event_t;
/* Sensor details (40 bytes) */
/** struct sensor_s is used to describe basic information about a specific sensor. */
typedefstruct
{
charname[12];/**< sensor name */
int32_tversion;/**< version of the hardware + driver */
int32_tsensor_id;/**< unique sensor identifier */
int32_ttype;/**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */
floatmax_value;/**< maximum value of this sensor's value in SI units */
floatmin_value;/**< minimum value of this sensor's value in SI units */
floatresolution;/**< smallest difference between two values reported by this sensor */
int32_tmin_delay;/**< min delay in microseconds between events. zero = not a constant rate */