Merge pull request #363 from BernardXiong/master

[Sensor] code cleanup
This commit is contained in:
Bernard Xiong 2014-11-01 15:54:00 +08:00
commit ecbde6bb9d
2 changed files with 112 additions and 98 deletions

View File

@ -55,7 +55,8 @@
* Availability: SENSORS_DEVICE_API_VERSION_1_0 * Availability: SENSORS_DEVICE_API_VERSION_1_0
* see (*batch)() documentation for details * see (*batch)() documentation for details
*/ */
enum { enum
{
SENSORS_BATCH_DRY_RUN = 0x00000001, SENSORS_BATCH_DRY_RUN = 0x00000001,
SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002
}; };
@ -63,7 +64,8 @@ enum {
/* /*
* what field for meta_data_event_t * what field for meta_data_event_t
*/ */
enum { enum
{
/* a previous flush operation has completed */ /* a previous flush operation has completed */
META_DATA_FLUSH_COMPLETE = 1, META_DATA_FLUSH_COMPLETE = 1,
META_DATA_VERSION /* always last, leave auto-assigned */ META_DATA_VERSION /* always last, leave auto-assigned */
@ -749,14 +751,17 @@ enum {
*/ */
typedef struct typedef struct
{ {
union { union
{
float v[3]; float v[3];
struct { struct
{
float x; float x;
float y; float y;
float z; float z;
}; };
struct { struct
{
float azimuth; float azimuth;
float pitch; float pitch;
float roll; float roll;
@ -771,17 +776,21 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
union { union
{
float uncalib[3]; float uncalib[3];
struct { struct
{
float x_uncalib; float x_uncalib;
float y_uncalib; float y_uncalib;
float z_uncalib; float z_uncalib;
}; };
}; };
union { union
{
float bias[3]; float bias[3];
struct { struct
{
float x_bias; float x_bias;
float y_bias; float y_bias;
float z_bias; float z_bias;
@ -799,7 +808,8 @@ typedef struct meta_data_event
* Union of the various types of sensor data * Union of the various types of sensor data
* that can be returned. * that can be returned.
*/ */
typedef struct sensors_event_t { typedef struct sensors_event_t
{
/* must be sizeof(struct sensors_event_t) */ /* must be sizeof(struct sensors_event_t) */
int32_t version; int32_t version;
@ -815,8 +825,10 @@ typedef struct sensors_event_t {
/* time is in nanosecond */ /* time is in nanosecond */
int64_t timestamp; int64_t timestamp;
union { union
union { {
union
{
float data[16]; float data[16];
/* acceleration values are in meter per second per second (m/s^2) */ /* acceleration values are in meter per second per second (m/s^2) */
@ -859,7 +871,8 @@ typedef struct sensors_event_t {
meta_data_event_t meta_data; meta_data_event_t meta_data;
}; };
union { union
{
uint64_t data[8]; uint64_t data[8];
/* step-counter */ /* step-counter */
@ -872,7 +885,8 @@ typedef struct sensors_event_t {
/* see SENSOR_TYPE_META_DATA */ /* see SENSOR_TYPE_META_DATA */
typedef sensors_event_t sensors_meta_data_event_t; typedef sensors_event_t sensors_meta_data_event_t;
typedef struct sensor_t { typedef struct sensor_t
{
/* Name of this sensor. /* Name of this sensor.
* All sensors of the same "type" must have a different "name". * All sensors of the same "type" must have a different "name".