2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <sensor_log.h>
19 #include <fusion_sensor.h>
22 #ifdef ENABLE_AUTO_ROTATION
23 #include "auto_rotation/auto_rotation_sensor.h"
26 #include "gravity/gravity_lowpass_sensor.h"
27 #include "gravity/gravity_comp_sensor.h"
29 #ifdef ENABLE_LINEAR_ACCEL
30 #include "linear_accel/linear_accel_sensor.h"
32 #ifdef ENABLE_ROTATION_VECTOR
33 #include "rotation_vector/rv_sensor.h"
34 #include "rotation_vector/magnetic_rv_sensor.h"
35 #include "rotation_vector/gyro_rv_sensor.h"
37 #ifdef ENABLE_ORIENTATION
38 #include "orientation/orientation_sensor.h"
40 #ifdef ENABLE_PEDOMETER
41 #include "pedometer/pedometer_sensor.h"
44 static std::vector<fusion_sensor_t> sensors;
46 template<typename _sensor>
47 void create_sensor(const char *name)
49 fusion_sensor *instance = NULL;
51 instance = new _sensor;
52 } catch (std::exception &e) {
53 _E("Failed to create %s sensor, exception: %s", name, e.what());
56 _ERRNO(err, _E, "Failed to create %s sensor device", name);
60 sensors.push_back(instance);
63 extern "C" int create(fusion_sensor_t **fsensors)
65 #ifdef ENABLE_AUTO_ROTATION
66 create_sensor<auto_rotation_sensor>("Accelerometer");
70 create_sensor<gravity_lowpass_sensor>("Gravity(Lowpass)");
71 create_sensor<gravity_comp_sensor>("Gravity(Complementary)");
74 #ifdef ENABLE_LINEAR_ACCEL
75 create_sensor<linear_accel_sensor>("Linear Acceleration Sensor");
78 #ifdef ENABLE_ROTATION_VECTOR
79 create_sensor<rv_sensor>("Rotation Vector Sensor");
80 create_sensor<magnetic_rv_sensor>("Magnetic Rotation Vector Sensor");
81 create_sensor<gyro_rv_sensor>("Gyroscope Rotation Vector Sensor");
84 #ifdef ENABLE_ORIENTATION
85 create_sensor<orientation_sensor>("Orientation Sensor");
88 #ifdef ENABLE_PEDOMETER
89 create_sensor<pedometer_sensor>("Pedometer");
92 *fsensors = &sensors[0];
93 return sensors.size();