commit
ecbde6bb9d
|
@ -19,7 +19,7 @@ int Sensor::GetType(void)
|
||||||
return this->type;
|
return this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sensor::Subscribe(SensorEventHandler_t *handler, void* user_data)
|
int Sensor::Subscribe(SensorEventHandler_t *handler, void *user_data)
|
||||||
{
|
{
|
||||||
this->evtHandler = handler;
|
this->evtHandler = handler;
|
||||||
this->userData = user_data;
|
this->userData = user_data;
|
||||||
|
@ -27,7 +27,7 @@ int Sensor::Subscribe(SensorEventHandler_t *handler, void* user_data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sensor::Publish(sensors_event_t* event)
|
int Sensor::Publish(sensors_event_t *event)
|
||||||
{
|
{
|
||||||
if (this->evtHandler != NULL)
|
if (this->evtHandler != NULL)
|
||||||
{
|
{
|
||||||
|
@ -53,9 +53,9 @@ SensorManager::~SensorManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int SensorManager::RegisterSensor(Sensor* sensor)
|
int SensorManager::RegisterSensor(Sensor *sensor)
|
||||||
{
|
{
|
||||||
SensorManager* self = &_sensor_manager;
|
SensorManager *self = &_sensor_manager;
|
||||||
|
|
||||||
RT_ASSERT(sensor != RT_NULL);
|
RT_ASSERT(sensor != RT_NULL);
|
||||||
|
|
||||||
|
@ -79,9 +79,9 @@ int SensorManager::RegisterSensor(Sensor* sensor)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SensorManager::DeregisterSensor(Sensor* sensor)
|
int SensorManager::DeregisterSensor(Sensor *sensor)
|
||||||
{
|
{
|
||||||
SensorManager* self = &_sensor_manager;
|
SensorManager *self = &_sensor_manager;
|
||||||
|
|
||||||
/* disconnect sensor list */
|
/* disconnect sensor list */
|
||||||
sensor->next->prev = sensor->prev;
|
sensor->next->prev = sensor->prev;
|
||||||
|
@ -102,7 +102,7 @@ int SensorManager::DeregisterSensor(Sensor* sensor)
|
||||||
|
|
||||||
Sensor *SensorManager::GetDefaultSensor(int type)
|
Sensor *SensorManager::GetDefaultSensor(int type)
|
||||||
{
|
{
|
||||||
SensorManager* self = &_sensor_manager;
|
SensorManager *self = &_sensor_manager;
|
||||||
Sensor *sensor = self->sensorList;
|
Sensor *sensor = self->sensorList;
|
||||||
|
|
||||||
if (sensor == NULL) return NULL;
|
if (sensor == NULL) return NULL;
|
||||||
|
@ -119,7 +119,7 @@ Sensor *SensorManager::GetDefaultSensor(int type)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SensorManager::Subscribe(int type, SensorEventHandler_t *handler, void* user_data)
|
int SensorManager::Subscribe(int type, SensorEventHandler_t *handler, void *user_data)
|
||||||
{
|
{
|
||||||
Sensor *sensor;
|
Sensor *sensor;
|
||||||
|
|
||||||
|
|
|
@ -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,15 +885,16 @@ 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".
|
||||||
*/
|
*/
|
||||||
const char* name;
|
const char *name;
|
||||||
|
|
||||||
/* vendor of the hardware part */
|
/* vendor of the hardware part */
|
||||||
const char* vendor;
|
const char *vendor;
|
||||||
|
|
||||||
/* version of the hardware part + driver. The value of this field
|
/* version of the hardware part + driver. The value of this field
|
||||||
* must increase when the driver is updated in a way that changes the
|
* must increase when the driver is updated in a way that changes the
|
||||||
|
@ -929,7 +943,7 @@ typedef struct sensor_t {
|
||||||
uint32_t fifoMaxEventCount;
|
uint32_t fifoMaxEventCount;
|
||||||
|
|
||||||
/* reserved fields, must be zero */
|
/* reserved fields, must be zero */
|
||||||
void* reserved[6];
|
void *reserved[6];
|
||||||
} sensor_t;
|
} sensor_t;
|
||||||
|
|
||||||
class SensorConfigure
|
class SensorConfigure
|
||||||
|
@ -939,7 +953,7 @@ class SensorConfigure
|
||||||
|
|
||||||
class Sensor;
|
class Sensor;
|
||||||
class SensorManager;
|
class SensorManager;
|
||||||
typedef void (*SensorEventHandler_t)(Sensor* sensor, sensors_event_t* event, void* user_data);
|
typedef void (*SensorEventHandler_t)(Sensor *sensor, sensors_event_t *event, void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sensor Base Class
|
* Sensor Base Class
|
||||||
|
@ -961,8 +975,8 @@ public:
|
||||||
|
|
||||||
int GetType(void);
|
int GetType(void);
|
||||||
|
|
||||||
int Subscribe(SensorEventHandler_t *handler, void* user_data);
|
int Subscribe(SensorEventHandler_t *handler, void *user_data);
|
||||||
int Publish(sensors_event_t* event);
|
int Publish(sensors_event_t *event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Sensor *next;
|
Sensor *next;
|
||||||
|
@ -983,14 +997,14 @@ public:
|
||||||
SensorManager();
|
SensorManager();
|
||||||
~SensorManager();
|
~SensorManager();
|
||||||
|
|
||||||
static int RegisterSensor(Sensor* sensor);
|
static int RegisterSensor(Sensor *sensor);
|
||||||
static int DeregisterSensor(Sensor* sensor);
|
static int DeregisterSensor(Sensor *sensor);
|
||||||
|
|
||||||
static Sensor *GetDefaultSensor(int type);
|
static Sensor *GetDefaultSensor(int type);
|
||||||
static int Subscribe(int type, SensorEventHandler_t *handler, void* user_data);
|
static int Subscribe(int type, SensorEventHandler_t *handler, void *user_data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Sensor* sensorList;
|
Sensor *sensorList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue