sensor: enable sensor HALs on rpi3 21/157221/2
authorkibak.yoon <kibak.yoon@samsung.com>
Mon, 23 Oct 2017 14:15:02 +0000 (23:15 +0900)
committerKibak Yoon <kibak.yoon@samsung.com>
Tue, 24 Oct 2017 00:58:37 +0000 (00:58 +0000)
Change-Id: I763f16dfdead3273cc3f525f493626734856b210
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/accelerometer/accelerometer_device.cpp
src/gyroscope/gyroscope_device.cpp
src/hrm_led_ir_red/hrm_led_ir_red_device.cpp
src/light/light_device.cpp
src/pressure/pressure_device.cpp
src/proximity/proximity_device.cpp

index 9f338b8..6ffda23 100644 (file)
 #include "accelerometer_device.h"
 #include "macro.h"
 
+#define GRAVITY 9.80665
+#define RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(X) (GRAVITY * (X))
+
 static sensor_info_t _sensor_infos[] = {
        {
                id: accelerometer_device::_accelerometer_id,
-               name: "SENSOR ACCELEROMETER",
+               name: "accelerometer",
                type: SENSOR_DEVICE_ACCELEROMETER,
                event_type: (SENSOR_DEVICE_ACCELEROMETER << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
                model_name: "LSM9DS0",
@@ -42,7 +45,7 @@ static sensor_info_t _sensor_infos[] = {
        },
        {       /* class seperate reason : Two sensors are same slave addess. but, they submit independent instances when application requests sensor info */
                id: accelerometer_device::_magnetometer_id,
-               name: "SENSOR GEOMAGNETIC",
+               name: "magnetometer",
                type: SENSOR_DEVICE_GEOMAGNETIC,
                event_type: (SENSOR_DEVICE_GEOMAGNETIC << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
                model_name: "LSM9DS0",
@@ -234,9 +237,9 @@ int accelerometer_device::get_data(uint32_t id, sensor_data_t **data, int *lengt
                        return 0;
                }
 
-               fdata[0] = accelerometer_data->ax;
-               fdata[1] = accelerometer_data->ay;
-               fdata[2] = accelerometer_data->az;
+               fdata[0] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(accelerometer_data->ax);
+               fdata[1] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(accelerometer_data->ay);
+               fdata[2] = RAW_DATA_TO_METRE_PER_SECOND_SQUARED_UNIT(accelerometer_data->az);
        } else if (id == accelerometer_device::_magnetometer_id) {
                if ((accelerometer_data = get_sensor_data(_magnetometer_index)) == NULL) {
                        *data = NULL;
@@ -293,6 +296,7 @@ bool accelerometer_device::on_accelerometer_tick()
        ac_data->ax = Adata[0];
        ac_data->ay = Adata[1];
        ac_data->az = Adata[2];
+       ac_data->timestamp = get_timestamp();
 
        fifo_cmd = accelerometer_device::_accelerometer_id;
        write_fifo(static_cast<void *>(&fifo_cmd), sizeof(int), written_bytes);
@@ -314,6 +318,7 @@ bool accelerometer_device::on_magnetometer_tick()
        ac_data->mx = Mdata[0];
        ac_data->my = Mdata[1];
        ac_data->mz = Mdata[2];
+       ac_data->timestamp = get_timestamp();
 
        fifo_cmd = accelerometer_device::_magnetometer_id;
        write_fifo(static_cast<void *>(&fifo_cmd), sizeof(int), written_bytes);
index 750c7c8..dc7db30 100644 (file)
@@ -12,7 +12,7 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * gyroscope_device
+ *
  */
 
 #include <fcntl.h>
 
 static sensor_info_t sensor_info = {
        id: 0x1,
-       name: "SENSOR GYROSCOPE",
+       name: "gyroscope",
        type: SENSOR_DEVICE_GYROSCOPE,
        event_type: (SENSOR_DEVICE_GYROSCOPE << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
        model_name: "LSM9DS0",
        vendor: "STMiroelectronics",
-       min_range: 245, // dps
+       min_range: -2000, // dps
        max_range: 2000, // dps
        resolution: 0.24, // dps
        min_interval: 50,
@@ -65,7 +65,7 @@ int gyroscope_device::get_sensors(const sensor_info_t **sensors)
 {
        *sensors = &sensor_info;
 
-       return sizeof(sensor_info) / sizeof(sensor_info_t);
+       return 1;
 }
 
 bool gyroscope_device::enable(uint32_t id)
@@ -127,7 +127,7 @@ int gyroscope_device::get_data(uint32_t id, sensor_data_t **data, int *length)
        *data = sensor_data;
        *length = sizeof(sensor_data_t);
 
-       return 1;
+       return 0;
 }
 
 bool gyroscope_device::flush(uint32_t id)
index 6433bca..c1ceebf 100644 (file)
 static const sensor_info_t _sensor_infos[] = {
        {
                id: hrm_led_ir_red_device::_led_red_id,
-               name: "SENSOR HRM LED RED",
+               name: "hrm_led_red",
                type: SENSOR_DEVICE_HRM_LED_RED,
                event_type: (SENSOR_DEVICE_HRM_LED_RED << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
                model_name: "MAX30100",
-               vendor: "Maxim Integrated",
+               vendor: "Maxim",
                min_range: 0, // adc count
                max_range: 0xffff, // adc count
                resolution: 1, // adc count
@@ -48,11 +48,11 @@ static const sensor_info_t _sensor_infos[] = {
        },
        {
                id: hrm_led_ir_red_device::_led_ir_id,
-               name: "SENSOR HRM LED IR",
+               name: "hrm_led_ir",
                type: SENSOR_DEVICE_HRM_LED_IR,
                event_type: (SENSOR_DEVICE_HRM_LED_IR << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
                model_name: "MAX30100",
-               vendor: "Maxim Integrated",
+               vendor: "Maxim",
                min_range: 0, // adc count
                max_range: 0xffff, // adc count
                resolution: 1, // adc count
index a26042c..4eb287a 100644 (file)
@@ -31,7 +31,7 @@
 
 static sensor_info_t sensor_info = {
        id: 0x1,
-       name: "SENSOR LIGHT",
+       name: "light",
        type: SENSOR_DEVICE_LIGHT,
        event_type: (SENSOR_DEVICE_LIGHT << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
        model_name: "TSL2651",
@@ -65,7 +65,7 @@ light_device::~light_device()
        _I("light_device is destroyed!");
 }
 
-int light_device::get_poll_fd()
+int light_device::get_poll_fd(void)
 {
        int poll_fd;
 
index b3a0707..c0d0f67 100644 (file)
@@ -34,7 +34,7 @@
 static const sensor_info_t _sensor_infos[] = {
        {
                id: pressure_device::_pressure_id,
-               name: "SENSOR PRESSURE",
+               name: "pressure",
                type: SENSOR_DEVICE_PRESSURE,
                event_type: (SENSOR_DEVICE_PRESSURE << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
                model_name: "BMP280",
@@ -48,7 +48,7 @@ static const sensor_info_t _sensor_infos[] = {
        },
        {
                id: pressure_device::_temperature_id,
-               name: "SENSOR TEMPERATURE",
+               name: "temperature",
                type: SENSOR_DEVICE_TEMPERATURE,
                event_type: (SENSOR_DEVICE_TEMPERATURE << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
                model_name: "BMP280",
index 97db386..20bde75 100644 (file)
@@ -24,7 +24,7 @@
 
 static sensor_info_t sensor_info = {
        id: 0x1,
-       name: "SENSOR PROXIMITY",
+       name: "proximity",
        type: SENSOR_DEVICE_PROXIMITY,
        event_type: (SENSOR_DEVICE_PROXIMITY << SENSOR_EVENT_SHIFT) | RAW_DATA_EVENT,
        model_name: "VCNL4010",