sensor-hal: add HAL interface for sensor_event_t 48/58748/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 3 Feb 2016 07:47:09 +0000 (16:47 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 3 Feb 2016 07:47:09 +0000 (16:47 +0900)
* 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>
src/interface/sensor_hal.h
src/plugins/accel/accel_sensor_hal.cpp
src/plugins/accel/accel_sensor_hal.h

index 435fad4..f7623a3 100644 (file)
@@ -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;
index a1950b2..21506bd 100755 (executable)
@@ -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;
index 199f0ec..6d28da9 100755 (executable)
@@ -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: