diff options
author | Mu-Woong Lee <muwoong.lee@samsung.com> | 2016-02-03 16:47:09 +0900 |
---|---|---|
committer | Mu-Woong Lee <muwoong.lee@samsung.com> | 2016-02-03 16:47:09 +0900 |
commit | 265594446f3c83615ca6b0c59a2e099352cfe764 (patch) | |
tree | d8abce7e08d85556ec5343f06b5cf58e67d1800d | |
parent | f3a70595eb2aae4da13bc59437531c73c3562245 (diff) | |
download | sensor-tm1-265594446f3c83615ca6b0c59a2e099352cfe764.tar.gz sensor-tm1-265594446f3c83615ca6b0c59a2e099352cfe764.tar.bz2 sensor-tm1-265594446f3c83615ca6b0c59a2e099352cfe764.zip |
sensor-hal: add HAL interface for sensor_event_t
* added sensor_get_sensor_event()
* implemented sensor_get_sensor_event() in accelerometer HAL
Change-Id: Id0555ced2da84b1916dea9fbea7074179e430dc8
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
-rw-r--r-- | src/interface/sensor_hal.h | 1 | ||||
-rwxr-xr-x | src/plugins/accel/accel_sensor_hal.cpp | 19 | ||||
-rwxr-xr-x | src/plugins/accel/accel_sensor_hal.h | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/interface/sensor_hal.h b/src/interface/sensor_hal.h index 435fad4..f7623a3 100644 --- a/src/interface/sensor_hal.h +++ b/src/interface/sensor_hal.h @@ -136,6 +136,7 @@ public: /* sensor fw read the data when is_data_ready() is true */ virtual bool is_data_ready() = 0; virtual bool get_sensor_data(uint32_t id, sensor_data_t &data) = 0; + virtual int get_sensor_event(uint32_t id, sensor_event_t **event) = 0; /* TODO: use get_sensors() instead of get_properties() */ virtual bool get_properties(uint32_t id, sensor_properties_s &properties) = 0; diff --git a/src/plugins/accel/accel_sensor_hal.cpp b/src/plugins/accel/accel_sensor_hal.cpp index a1950b2..21506bd 100755 --- a/src/plugins/accel/accel_sensor_hal.cpp +++ b/src/plugins/accel/accel_sensor_hal.cpp @@ -370,6 +370,25 @@ bool accel_sensor_hal::get_sensor_data(uint32_t id, sensor_data_t &data) return true; } +int accel_sensor_hal::get_sensor_event(uint32_t id, sensor_event_t **event) +{ + sensor_event_t *sensor_event; + sensor_event = (sensor_event_t *)malloc(sizeof(sensor_event_t)); + + sensor_event->data.accuracy = SENSOR_ACCURACY_GOOD; + sensor_event->data.timestamp = m_fired_time; + sensor_event->data.value_count = 3; + sensor_event->data.values[0] = m_x; + sensor_event->data.values[1] = m_y; + sensor_event->data.values[2] = m_z; + + raw_to_base(sensor_event->data); + + *event = sensor_event; + + return sizeof(sensor_event_t); +} + void accel_sensor_hal::raw_to_base(sensor_data_t &data) { data.value_count = 3; diff --git a/src/plugins/accel/accel_sensor_hal.h b/src/plugins/accel/accel_sensor_hal.h index 199f0ec..6d28da9 100755 --- a/src/plugins/accel/accel_sensor_hal.h +++ b/src/plugins/accel/accel_sensor_hal.h @@ -38,6 +38,7 @@ public: bool set_command(uint32_t id, std::string command, std::string value); bool is_data_ready(void); bool get_sensor_data(uint32_t id, sensor_data_t &data); + int get_sensor_event(uint32_t id, sensor_event_t **event); bool get_properties(uint32_t id, sensor_properties_s &properties); private: |