Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:46:11 +0000 (01:46 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:46:11 +0000 (01:46 +0900)
14 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0755]
capi-system-sensor.manifest [new file with mode: 0644]
capi-system-sensor.pc.in [new file with mode: 0644]
include/sensor_private.h [new file with mode: 0644]
include/sensors.h [new file with mode: 0755]
packaging/capi-system-sensor.spec [new file with mode: 0644]
phone_facedown.png [new file with mode: 0755]
phone_panning.png [new file with mode: 0755]
phone_snap.png [new file with mode: 0755]
src/fusion_util.c [new file with mode: 0644]
src/geomanetic_field.c [new file with mode: 0755]
src/sensor.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..0a63eea
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Pius Lee <pius.lee@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2e1b040
--- /dev/null
@@ -0,0 +1,95 @@
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-sensor")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog sensor capi-base-common")
+SET(pc_dependents "capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fdump-rtl-expand")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+    PROPERTIES
+    VERSION ${FULLVER}
+    SOVERSION ${MAJORVER}
+    CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/system
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+
+CONFIGURE_FILE(
+    ${fw_name}.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean 
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    . 
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
+
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..bbe9d02
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/capi-system-sensor.manifest b/capi-system-sensor.manifest
new file mode 100644 (file)
index 0000000..41a9320
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
+
diff --git a/capi-system-sensor.pc.in b/capi-system-sensor.pc.in
new file mode 100644 (file)
index 0000000..316fa51
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/system
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir} 
+
diff --git a/include/sensor_private.h b/include/sensor_private.h
new file mode 100644 (file)
index 0000000..d699b50
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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. 
+ */
+
+
+
+
+#ifndef __SENSOR_PRIVATE_H__
+#define __SENSOR_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+enum _sensor_ids_index{
+       ID_ACCELEOMETER,
+       ID_GEOMAGNETIC,
+       ID_GYROSCOPE,
+       ID_LIGHT,
+       ID_PROXIMITY,
+       ID_MOTION,
+       ID_NUMBERS
+};
+
+#define CB_NUMBERS (SENSOR_LAST)
+#define CALIB_CB_NUMBERS (SENSOR_ORIENTATION+1)
+#define WAKEUP_CB_NUMBERS (SENSOR_DEVICE_ORIENTATION+1)
+#define EMPTY_EVENT 0
+
+struct sensor_handle_s {
+       int ids[ID_NUMBERS];
+       int started[CB_NUMBERS];
+       int sensor_option[CB_NUMBERS];
+
+       void* cb_func[CB_NUMBERS];
+       void* cb_user_data[CB_NUMBERS];
+
+       void* calib_func[CALIB_CB_NUMBERS];
+       void* calib_user_data[CALIB_CB_NUMBERS];
+
+       void* wakeup_func[WAKEUP_CB_NUMBERS];
+       void* wakeup_user_data[WAKEUP_CB_NUMBERS];
+};
+
+#define SENSOR_INIT(handle) \
+do { \
+       handle->ids[ID_ACCELEOMETER] = -1; \
+       handle->ids[ID_GEOMAGNETIC] = -1; \
+       handle->ids[ID_GYROSCOPE] = -1; \
+       handle->ids[ID_LIGHT] = -1; \
+       handle->ids[ID_PROXIMITY] = -1; \
+       handle->ids[ID_MOTION] = -1; \
+       handle->started[SENSOR_ACCELEROMETER] = 0; \
+       handle->started[SENSOR_GRAVITY] = 0; \
+       handle->started[SENSOR_LINEAR_ACCELERATION] = 0; \
+       handle->started[SENSOR_DEVICE_ORIENTATION] = 0; \
+       handle->started[SENSOR_MAGNETIC] = 0; \
+       handle->started[SENSOR_ORIENTATION] = 0; \
+       handle->started[SENSOR_GYROSCOPE] = 0; \
+       handle->started[SENSOR_LIGHT] = 0; \
+       handle->started[SENSOR_PROXIMITY] = 0; \
+       handle->started[SENSOR_MOTION_SNAP] = 0; \
+       handle->started[SENSOR_MOTION_SHAKE] = 0; \
+       handle->started[SENSOR_MOTION_DOUBLETAP] = 0; \
+       handle->started[SENSOR_MOTION_PANNING] = 0; \
+       handle->started[SENSOR_MOTION_PANNING_BROWSE] = 0; \
+       handle->started[SENSOR_MOTION_TILT] = 0; \
+       handle->started[SENSOR_MOTION_FACEDOWN] = 0; \
+       handle->started[SENSOR_MOTION_DIRECTCALL] = 0; \
+       handle->started[SENSOR_MOTION_SMART_ALERT] = 0; \
+       handle->started[SENSOR_MOTION_NO_MOVE] = 0; \
+       handle->sensor_option[SENSOR_ACCELEROMETER] = 0; \
+       handle->sensor_option[SENSOR_GRAVITY] = 0; \
+       handle->sensor_option[SENSOR_LINEAR_ACCELERATION] = 0; \
+       handle->sensor_option[SENSOR_DEVICE_ORIENTATION] = 0; \
+       handle->sensor_option[SENSOR_MAGNETIC] = 0; \
+       handle->sensor_option[SENSOR_ORIENTATION] = 0; \
+       handle->sensor_option[SENSOR_GYROSCOPE] = 0; \
+       handle->sensor_option[SENSOR_LIGHT] = 0; \
+       handle->sensor_option[SENSOR_PROXIMITY] = 0; \
+       handle->sensor_option[SENSOR_MOTION_SNAP] = 0; \
+       handle->sensor_option[SENSOR_MOTION_SHAKE] = 0; \
+       handle->sensor_option[SENSOR_MOTION_DOUBLETAP] = 0; \
+       handle->sensor_option[SENSOR_MOTION_PANNING] = 0; \
+       handle->sensor_option[SENSOR_MOTION_PANNING_BROWSE] = 0; \
+       handle->sensor_option[SENSOR_MOTION_TILT] = 0; \
+       handle->sensor_option[SENSOR_MOTION_FACEDOWN] = 0; \
+       handle->sensor_option[SENSOR_MOTION_DIRECTCALL] = 0; \
+       handle->sensor_option[SENSOR_MOTION_SMART_ALERT] = 1; \
+       handle->sensor_option[SENSOR_MOTION_NO_MOVE] = 0; \
+       handle->cb_func[SENSOR_ACCELEROMETER] = NULL; \
+       handle->cb_func[SENSOR_GRAVITY] = NULL; \
+       handle->cb_func[SENSOR_LINEAR_ACCELERATION] = NULL; \
+       handle->cb_func[SENSOR_DEVICE_ORIENTATION] = NULL; \
+       handle->cb_func[SENSOR_MAGNETIC] = NULL; \
+       handle->cb_func[SENSOR_ORIENTATION] = NULL; \
+       handle->cb_func[SENSOR_GYROSCOPE] = NULL; \
+       handle->cb_func[SENSOR_LIGHT] = NULL; \
+       handle->cb_func[SENSOR_PROXIMITY] = NULL; \
+       handle->cb_func[SENSOR_MOTION_SNAP] = NULL; \
+       handle->cb_func[SENSOR_MOTION_SHAKE] = NULL; \
+       handle->cb_func[SENSOR_MOTION_DOUBLETAP] = NULL; \
+       handle->cb_func[SENSOR_MOTION_PANNING] = NULL; \
+       handle->cb_func[SENSOR_MOTION_PANNING_BROWSE] = NULL; \
+       handle->cb_func[SENSOR_MOTION_TILT] = NULL; \
+       handle->cb_func[SENSOR_MOTION_FACEDOWN] = NULL; \
+       handle->cb_func[SENSOR_MOTION_DIRECTCALL] = NULL; \
+       handle->cb_func[SENSOR_MOTION_SMART_ALERT] = NULL; \
+       handle->cb_func[SENSOR_MOTION_NO_MOVE] = NULL; \
+       handle->cb_user_data[SENSOR_ACCELEROMETER] = NULL; \
+       handle->cb_user_data[SENSOR_GRAVITY] = NULL; \
+       handle->cb_user_data[SENSOR_LINEAR_ACCELERATION] = NULL; \
+       handle->cb_user_data[SENSOR_DEVICE_ORIENTATION] = NULL; \
+       handle->cb_user_data[SENSOR_MAGNETIC] = NULL; \
+       handle->cb_user_data[SENSOR_ORIENTATION] = NULL; \
+       handle->cb_user_data[SENSOR_GYROSCOPE] = NULL; \
+       handle->cb_user_data[SENSOR_LIGHT] = NULL; \
+       handle->cb_user_data[SENSOR_PROXIMITY] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_SNAP] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_SHAKE] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_DOUBLETAP] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_PANNING] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_PANNING_BROWSE] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_TILT] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_FACEDOWN] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_DIRECTCALL] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_SMART_ALERT] = NULL; \
+       handle->cb_user_data[SENSOR_MOTION_NO_MOVE] = NULL; \
+       handle->calib_func[SENSOR_ACCELEROMETER] = NULL; \
+       handle->calib_func[SENSOR_GRAVITY] = NULL; \
+       handle->calib_func[SENSOR_LINEAR_ACCELERATION] = NULL; \
+       handle->calib_func[SENSOR_DEVICE_ORIENTATION] = NULL; \
+       handle->calib_func[SENSOR_MAGNETIC] = NULL; \
+       handle->calib_func[SENSOR_ORIENTATION] = NULL; \
+       handle->calib_user_data[SENSOR_ACCELEROMETER] = NULL; \
+       handle->calib_user_data[SENSOR_GRAVITY] = NULL; \
+       handle->calib_user_data[SENSOR_LINEAR_ACCELERATION] = NULL; \
+       handle->calib_user_data[SENSOR_DEVICE_ORIENTATION] = NULL; \
+       handle->calib_user_data[SENSOR_MAGNETIC] = NULL; \
+       handle->calib_user_data[SENSOR_ORIENTATION] = NULL; \
+       handle->wakeup_func[SENSOR_ACCELEROMETER] = NULL; \
+       handle->wakeup_user_data[SENSOR_ACCELEROMETER] = NULL;\
+}while(0) \
+
+float clamp(float v);
+int getAngleChange(float *R, float *prevR, float *angleChange);
+int quatToMatrix(float *quat, float *R);
+int matrixToQuat(float *mat, float *q);
+int getRotationMatrix(float *accel, float *geo, float *R, float *I);
+int remapCoordinateSystem(float *inR, int X, int Y, float *outR);
+int getDeclination(float *decl);
+int getInclination(float *incl);
+int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __SENSOR_PRIVATE_H__ 
diff --git a/include/sensors.h b/include/sensors.h
new file mode 100755 (executable)
index 0000000..755df08
--- /dev/null
@@ -0,0 +1,2229 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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. 
+ */
+
+
+
+
+#ifndef __SENSOR_H__
+#define __SENSOR_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_MODULE
+ * @{
+ */
+
+/**
+ * @brief The sensor handle.
+ */
+typedef struct sensor_handle_s* sensor_h;
+
+/**
+* @brief       Enumerations of sensor data accuracy.
+*/
+typedef enum
+{
+       SENSOR_DATA_ACCURACY_UNDEFINED   = -1,  /**< Undefined accuracy */
+       SENSOR_DATA_ACCURACY_BAD         = 0,   /**< Bad accuracy */
+       SENSOR_DATA_ACCURACY_NORMAL      = 1,   /**< Normal accuracy */
+       SENSOR_DATA_ACCURACY_GOOD        = 2,   /**< Good accuracy */
+       SENSOR_DATA_ACCURACY_VERYGOOD    = 3    /**< Very good accuracy */
+} sensor_data_accuracy_e;
+
+
+/**
+* @brief       Enumerations of error code for sensor.
+ */
+typedef enum
+{
+       SENSOR_ERROR_NONE                  = TIZEN_ERROR_NONE,                   /**< Successful */
+       SENSOR_ERROR_IO_ERROR              = TIZEN_ERROR_IO_ERROR,             /**< I/O error */
+       SENSOR_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
+       SENSOR_ERROR_OUT_OF_MEMORY         = TIZEN_ERROR_SYSTEM_CLASS | 0x02,  /**< Out of memory */
+       SENSOR_ERROR_NOT_NEED_CALIBRATION  = TIZEN_ERROR_SYSTEM_CLASS | 0x03,  /**< Sensor doesn't need calibration */
+       SENSOR_ERROR_NOT_SUPPORTED         = TIZEN_ERROR_SYSTEM_CLASS | 0x04,  /**< Unsupported sensor in current device */
+       SENSOR_ERROR_OPERATION_FAILED      = TIZEN_ERROR_SYSTEM_CLASS | 0x06,  /**< Operation failed */
+
+} sensor_error_e;
+
+
+/**
+* @brief       Enumerations of sensor type.
+*/
+typedef enum
+{
+       SENSOR_ACCELEROMETER,                    /**< Accelerometer */
+       SENSOR_GRAVITY,                          /**< Gravity sensor */
+       SENSOR_LINEAR_ACCELERATION,              /**< Linear acceleration sensor */
+       SENSOR_DEVICE_ORIENTATION,               /**< Device orientation sensor */
+       SENSOR_MAGNETIC,                         /**< Magnetic sensor */
+       SENSOR_ORIENTATION,                      /**< Orientation sensor */
+       SENSOR_GYROSCOPE,                        /**< Gyroscope sensor */
+       SENSOR_LIGHT,                            /**< Light sensor */
+       SENSOR_PROXIMITY,                        /**< Proximity sensor */
+       SENSOR_MOTION_SNAP,                      /**< Snap motion sensor */
+       SENSOR_MOTION_SHAKE,                     /**< Shake motion sensor */
+       SENSOR_MOTION_DOUBLETAP,                 /**< Double tap motion sensor */
+       SENSOR_MOTION_PANNING,                   /**< Panning motion sensor */
+       SENSOR_MOTION_PANNING_BROWSE,            /**< Panning browse motion sensor */
+       SENSOR_MOTION_TILT,                      /**< Tilt motion sensor */
+       SENSOR_MOTION_FACEDOWN,                  /**< Face to down motion sensor */
+       SENSOR_MOTION_DIRECTCALL,                /**< Direct call motion sensor */
+       SENSOR_MOTION_SMART_ALERT,               /**< Smart alert motion sensor */
+       SENSOR_MOTION_NO_MOVE,                   /**< No move motion sensor */
+       SENSOR_LAST                              /**< End of sensor enum values */
+} sensor_type_e;
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SNAP_MODULE
+ * @{
+ */
+
+/**
+ * @brief      Enumerations of snap motion event.
+ */
+typedef enum
+{
+       SENSOR_MOTION_SNAP_NONE,            /**< No Snap */
+       SENSOR_MOTION_SNAP_LEFT,            /**< Snap left to right */
+       SENSOR_MOTION_SNAP_RIGHT,           /**< Snap right to left */
+       SENSOR_MOTION_SNAP_X_POSITIVE = SENSOR_MOTION_SNAP_RIGHT, /**< Snap to positive direction in X-axis, it is the same as @SENSOR_MOTION_SNAP_RIGHT */
+       SENSOR_MOTION_SNAP_X_NEGATIVE = SENSOR_MOTION_SNAP_LEFT, /**< Snap to negative direction in X-axis, it is the same as @SENSOR_MOTION_SNAP_LEFT */
+       SENSOR_MOTION_SNAP_Y_POSITIVE, /**< Snap to positive direction in Y-axis */
+       SENSOR_MOTION_SNAP_Y_NEGATIVE, /**< Snap to Negative direction in Y-axis */
+       SENSOR_MOTION_SNAP_Z_POSITIVE, /**< Snap to positive direction in Z-axis */
+       SENSOR_MOTION_SNAP_Z_NEGATIVE, /**< Snap to Negative direction in Z-axis */
+} sensor_motion_snap_e;
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SHAKE_MODULE
+ * @{
+ */
+
+/**
+ * @brief      Enumerations of shake motion event.
+ */
+typedef enum
+{
+       SENSOR_MOTION_SHAKE_NONE,                /**< No Shake */
+       SENSOR_MOTION_SHAKE_DETECTED,            /**< Shake motion detected */
+       SENSOR_MOTION_SHAKE_CONTINUING,          /**< Shake motion continuing */
+       SENSOR_MOTION_SHAKE_FINISHED,            /**< Shake motion finished */
+       SENSOR_MOTION_SHAKE_BROKEN,              /**< Shake motion broken */
+} sensor_motion_shake_e;
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when the current sensor reading falls outside of a defined normal range.
+ *
+ * @details When something is artificially influencing, such as ferrous metal objects or 
+ * electromagnetic fields (car electrical systems, automobile engines, steel pitons, etc.), this callback is called.
+ * One way of implementing this callback is to notice a user to make big 8-like gesture with device.
+ *
+ * @param[in] user_data        The user data passed from the callback registration function
+ *
+ * @see sensor_magnetic_set_calibration_cb()
+ * @see sensor_magnetic_unset_calibration_cb()
+ * @see sensor_orientation_set_calibration_cb()
+ * @see sensor_orientation_unset_calibration_cb()
+ */
+typedef void (*sensor_calibration_cb)(void *user_data);
+
+
+/**
+ * @brief Checks whether the given sensor type is available on a device.
+ * @details
+ * You need to check availability of a sensor first because this sensor may not be supported on the device.
+ *
+ * @param[in]   type        The sensor type to check
+ * @param[out]  supported   @c true if this sensor type is supported, otherwise @c false
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ *
+ */
+int sensor_is_supported(sensor_type_e type, bool *supported);
+
+
+/**
+ * @brief Gets data specification for a sensor type, except motion sensors.
+ *
+ * @remark When the given @a type is one of the motion sensors, this function returns #SENSOR_ERROR_INVALID_PARAMETER.
+ *
+ * @param[in]   type         The sensor type to check
+ * @param[out]  vendor       The vendor name of the sensor
+ * @param[out]  model        The model name of the sensor
+ * @param[out]  max          The maximum range of the sensor in the sensor's unit 
+ * @param[out]  min          The minimum range of the sensor in the sensor's unit
+ * @param[out]  resolution   The resolution of the sensor
+ *
+ * @return      0 on success, otherwise a negative error value.
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_NOT_SUPPORTED         The sensor type is not supported in current device
+ *
+ * @pre #sensor_is_supported()
+ */
+int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float *max, float *min, float *resolution);
+
+
+/**
+ * @brief Creates a sensor handle.
+ *
+ * @remarks @a sensor must be released sensor_destroy() by you.
+ *
+ * @param[out] sensor  A new sensor handle to the sensors
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE               Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval      #SENSOR_ERROR_OUT_OF_MEMORY      Out of memory
+ *
+ * @see sensor_destroy()
+ */
+int sensor_create(sensor_h *sensor);
+
+
+/**
+ * @brief Destroys the sensor handle and releases all its resources.
+ *
+ * @remark After this function is called, the attached sensor will be detached and 
+ *             the corresponding sensor connection will be released.
+ *
+ * @param[in] sensor   The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ *
+ * @see sensor_create()
+ */
+int sensor_destroy(sensor_h sensor);
+
+
+/**
+ * @brief Starts sensor server for the given sensor handle and sensor type.
+ * @details
+ * After this function is called, sensor events will occur and 
+ * the specific sensor type related callback function will be called. An application can read sensor data.
+ *
+ * @param[in] sensor  The sensor handle
+ * @param[in] type    The sensor type
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_NOT_SUPPORTED         The sensor type is not supported in current device
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @pre call sensor_create() before using this function.
+ * @post This function invokes sensor_calibration_cb(), sensor_accelerometer_event_cb(), sensor_magnetic_event_cb(),
+ * sensor_orientation_event_cb(), sensor_gyroscope_event_cb(), sensor_light_event_cb(),
+ * sensor_proximity_event_cb(), sensor_motion_snap_event_cb(), sensor_motion_shake_event_cb(),
+ * sensor_motion_doubletap_event_cb(), sensor_motion_panning_event_cb(), or sensor_motion_facedown_event_cb().
+ *
+ * @see sensor_stop()
+ */
+int sensor_start(sensor_h sensor, sensor_type_e type);
+
+
+/**
+ * @brief Stops sensor server for the given sensor handle and type.
+ * @details The given @a type event will not occur any more and the callback functions also won't be called.
+ *
+ * @param[in]   sensor  The sensor handle
+ * @param[in]   type    The sensor type
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ *
+ * @see sensor_start()
+ */
+int sensor_stop(sensor_h sensor, sensor_type_e type);
+
+/**
+ * @brief Retrieve minimum and maximum interval time that can use to measuring specific sensor.
+ *
+ * @param[in]  type    The sensor type
+ * @param[out] min     The minimum interval time
+ * @param[out] max     The maximum interval time
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ */
+int sensor_get_delay_boundary(sensor_type_e type, int *min, int *max);
+
+/**
+ * @brief Retrieve whether supported or not supported the awaken from specific sensor.
+ *
+ * @param[in]   type         The sensor type
+ * @param[out]  supported    @c true if this sensor type is supported, otherwise @c false
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ */
+int sensor_awake_is_supported(sensor_type_e type, bool *supported);
+
+/**
+ * @brief Set the awaken behavior from specific sensor.
+ *
+ * @param[in]   sensor       The sensor handle
+ * @param[in]   type         The sensor type
+ * @param[out]  enable       @c true if set enable the awaken behavior from the sensor, or @c false
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ */
+int sensor_awake_is_enabled(sensor_h sensor, sensor_type_e type, bool *enable);
+
+/**
+ * @brief Called when a device awaken.
+ *
+ * @param[in] user_data     The user data passed from the callback registration function
+ *
+ * @see sensor_awake_is_supported()
+ * @see sensor_awake_set()
+ * @see sensor_awake_set_cb()
+ * @see sensor_awake_unset_cb()
+ */
+typedef void (*sensor_awake_cb) (void *user_data);
+
+/**
+ * @brief Set the callback that called when device awaken.
+ * 
+ * @param[in]   sensor  The sensor handle
+ * @param[in]   type         The sensor type
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ */
+int sensor_awake_set_cb(sensor_h sensor, sensor_type_e type, sensor_awake_cb callback, void* user_data);
+
+/**
+ * @brief Unset the callback that called when device awaken.
+ * 
+ * @param[in]   sensor   The sensor handle
+ * @param[in]   type         The sensor type
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ */
+int sensor_awake_unset_cb(sensor_h sensor, sensor_type_e type);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_ACCELEROMETER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an accelerometer event occurs.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             The acceleration Gx on the x-axis in [m/s^2]
+ * @param[in] y             The acceleration Gy on the y-axis in [m/s^2]
+ * @param[in] z             The acceleration Gz on the z-axis in [m/s^2]
+ * @param[in] user_data     The user data passed from the callback registration function
+ *
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_accelerometer_set_cb().
+ *
+ * @see sensor_accelerometer_set_cb()
+ * @see sensor_accelerometer_unset_cb()
+ */
+typedef void (*sensor_accelerometer_event_cb)( unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
+
+
+/**
+ * @brief      Registers a callback function to be invoked when an accelerometer event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms    The interval sensor events are delivered at (in milliseconds) \n
+ *                                                     If @a rate is zero, it uses default value(100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_accelerometer_event_cb() will be invoked.
+ *
+ * @see sensor_accelerometer_event_cb()
+ * @see sensor_accelerometer_unset_cb()
+ */
+int sensor_accelerometer_set_cb(sensor_h sensor, int interval_ms, sensor_accelerometer_event_cb callback, void *user_data);
+
+
+/**
+ * @brief      Unregister the accelerometer callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_accelerometer_set_cb()
+ */
+int sensor_accelerometer_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at accelerometer measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED        Operation failed
+ *
+ * @see sensor_accelerometer_set_cb()
+ */
+int sensor_accelerometer_set_interval(sensor_h sensor, int interval_ms);
+
+
+/**
+ * @brief      Gets sensor data from the accelerometer sensor.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[out]  x           The acceleration minus Gx on the x-axis in meters per second squared (m/s^2)
+ * @param[out]  y           The acceleration minus Gy on the y-axis in meters per second squared (m/s^2)
+ * @param[out]  z           The acceleration minus Gz on the z-axis in meters per second squared (m/s^2)
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ */
+int sensor_accelerometer_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_GRAVITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an gravity event occurs.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             g (9.8 m/s^2 = 1g)
+ * @param[in] y             g (9.8 m/s^2 = 1g)
+ * @param[in] z             g (9.8 m/s^2 = 1g)
+ * @param[in] user_data     The user data passed from the callback registration function
+ *
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_rotation_vector_set_cb().
+ *
+ * @see sensor_gravity_set_cb()
+ * @see sensor_gravity_unset_cb()
+ */
+typedef void (*sensor_gravity_event_cb)(unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when an gravity event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms The interval sensor events are delivered at (in milliseconds) \n
+ *                                                     If @a rate is zero, it uses default value(100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_gravity_event_cb() will be invoked.
+ *
+ * @see sensor_gravity_event_cb()
+ * @see sensor_gravity_unset_cb()
+ */
+int sensor_gravity_set_cb(sensor_h sensor, int interval_ms, sensor_gravity_event_cb callback, void* user_data);
+
+/**
+ * @brief      Unregister the gravity callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_gravity_set_cb()
+ */
+int sensor_gravity_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at gravity measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_gravity_set_cb()
+ */
+int sensor_gravity_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief      Gets sensor data from the gravity sensor.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[in] x             g (9.8 m/s^2 = 1g)
+ * @param[in] y             g (9.8 m/s^2 = 1g)
+ * @param[in] z             g (9.8 m/s^2 = 1g)
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ */
+int sensor_gravity_read_data(sensor_h sensor, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_LINEAR_ACCELERATION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an linear accleration event occurs.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             The acceleration Gx on the x-axis in [m/s^2] not including gravity
+ * @param[in] y             The acceleration Gy on the y-axis in [m/s^2] not including gravity
+ * @param[in] z             The acceleration Gz on the z-axis in [m/s^2] not including gravity
+ * @param[in] user_data     The user data passed from the callback registration function
+ *
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_linear_acceleration_set_cb().
+ *
+ * @see sensor_linear_acceleration_set_cb()
+ * @see sensor_linear_acceleration_unset_cb()
+ */
+typedef void (*sensor_linear_acceleration_event_cb)( unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when an linear acceleration event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms    The interval sensor events are delivered at (in milliseconds) \n
+ *                                                     If @a rate is zero, it uses default value(100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_linear_acceleration_event_cb() will be invoked.
+ *
+ * @see sensor_linear_acceleration_event_cb()
+ * @see sensor_linear_acceleration_unset_cb()
+ */
+int sensor_linear_acceleration_set_cb(sensor_h sensor, int interval_ms, sensor_linear_acceleration_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the linear acceleration callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_linear_acceleration_set_cb()
+ */
+int sensor_linear_acceleration_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at linear acceleration measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_linear_acceleration_set_cb()
+ */
+int sensor_linear_acceleration_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief      Gets sensor data from the linear acceleration sensor.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[out]  x           The acceleration Gx on the x-axis in meters per second squared (m/s^2) not including gravity
+ * @param[out]  y           The acceleration Gy on the y-axis in meters per second squared (m/s^2) not including gravity
+ * @param[out]  z           The acceleration Gz on the z-axis in meters per second squared (m/s^2) not including gravity
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ */
+int sensor_linear_acceleration_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
+
+
+/**
+ * @}
+ * 
+ * @addtogroup CAPI_SYSTEM_SENSOR_DEVICE_ORIENTATION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an device orientation event occurs.
+ *
+ * @remark  All values are angles in degrees.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a yaw, @a pitch, and @a roll values
+ * @param[in] yaw           The rotation around z-axis [0 ~ 360], with positive values when the y-axis moves \n
+ *                          toward the x-axis
+ * @param[in] pitch         The rotation around x-axis [-180 ~ 180], with positive values when the z-axis moves \n
+ *                          toward the y-axis
+ * @param[in] roll          The rotation around y-axis [-90 ~ 90], with positive values when the x-axis moves \n
+ *                          toward the z-axis
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_device_orientation_set_cb().
+ * @see sensor_device_orientation_set_cb()
+ * @see sensor_device_orientation_unset_cb()
+ */
+typedef void (*sensor_device_orientation_event_cb)( unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float yaw, float pitch, float roll, void *user_data);
+               
+/**
+ * @brief      Registers a callback function to be invoked when an device orientation event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms    The interval sensor events are delivered in (in milliseconds) \n
+ *                          If @a interval_ms is zero, it uses default value (100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function 
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_device_orientation_event_cb() will be invoked.
+ *
+ * @see sensor_device_orientation_event_cb()
+ * @see sensor_device_orientation_unset_cb()
+*/
+int sensor_device_orientation_set_cb(sensor_h sensor, int interval_ms, sensor_device_orientation_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the device orientation callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_device_orientation_set_cb()
+ */
+int sensor_device_orientation_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at orientation measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED        Operation failed
+ *
+ * @see sensor_device_orientation_set_cb()
+ */
+int sensor_orientation_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief Gets sensor data from the device orientation sensor.
+ *
+ * @remark
+ * All values are angles in degrees.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[in]   yaw         The rotation around z-axis [0 ~ 360], with positive values when the y-axis moves \n
+ *                          toward the x-axis
+ * @param[out]  pitch       The rotation in degrees around x-axis [-180 ~ 180], with positive values when the \n
+ *                          z-axis moves toward the y-axis
+ * @param[out]  roll        The rotation in degrees around y-axis [-90 ~ 90], with positive values when the \n
+ *                          x-axis moves toward the z-axis
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ * @see sensor_start()
+ */
+int sensor_device_orientation_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *yaw, float *pitch, float *roll);
+
+
+/**
+ * @}
+ * 
+ * @addtogroup CAPI_SYSTEM_SENSOR_MAGNETIC_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a magnetic event occurs.
+ *
+ * @remark @a x, @a y, and @a z values are in micro-Teslas(uT) and measure the ambient magnetic field in the X, Y and Z axis.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             Micro-Tesla value from ambient magnetic field on the x-axis
+ * @param[in] y             Micro-Tesla value from ambient magnetic field on the y-axis
+ * @param[in] z             Micro-Tesla value from ambient magnetic field on the z-axis
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_magnetic_set_cb().
+ * @see sensor_magnetic_set_cb()
+ * @see sensor_magnetic_unset_cb()
+ */
+typedef void (*sensor_magnetic_event_cb)( unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
+                               
+/**
+ * @brief      Registers a callback function to be invoked when a magnetic event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms    The interval sensor events are delivered in (in milliseconds) \n
+ *                          If @a interval_ms is zero, it uses default value (100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_magnetic_event_cb() will be invoked.
+ *
+ * @see sensor_magnetic_event_cb()
+ * @see        sensor_magnetic_unset_cb()
+ */
+int sensor_magnetic_set_cb(sensor_h sensor, int interval_ms, sensor_magnetic_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the magnetic callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_magnetic_set_cb()
+ */
+int sensor_magnetic_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at magnetic sensor measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_magnetic_set_cb()
+ */
+int sensor_magnetic_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief Gets sensor data from the magnetic sensor.
+ *
+ * @remark All values are in micro-Teslas (uT) and measure the ambient magnetic field in the X, Y and Z axis.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[out]  x           Micro-Tesla value on the x-axis
+ * @param[out]  y           Micro-Tesla value on the y-axis
+ * @param[out]  z           Micro-Tesla value on the z-axis
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ *
+ * @see sensor_start()
+ */
+int sensor_magnetic_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
+
+/**
+ * @brief      Registers a callback function to be invoked when the current sensor reading falls outside of a defined normal range.
+ *
+ * @param[in]   sensor     The sensor handle
+ * @param[in]   callback   The callback function to register
+ * @param[in]   user_data  The user data to be passed to the callback function
+ *
+ * @return             0 on success, otherwise a negative error value
+ * @retval             #SENSOR_ERROR_NONE                  Successful
+ * @retval             #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval             #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval             #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ * @retval             #SENSOR_ERROR_NOT_NEED_CALIBRATION      Sensor doesn't need calibration
+ *
+ * @post sensor_calibration_cb() will be invoked.
+ *
+ * @see sensor_calibration_cb()
+ * @see        sensor_magnetic_unset_calibration_cb()
+ */
+int sensor_magnetic_set_calibration_cb(sensor_h sensor, sensor_calibration_cb callback, void *user_data);
+
+/**
+ * @brief      Unregisters the magnetic calibration callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ * @retval             #SENSOR_ERROR_NOT_NEED_CALIBRATION      Sensor doesn't need calibration
+ * @see sensor_magnetic_set_calibration_cb()
+ */
+int sensor_magnetic_unset_calibration_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ * 
+ * @addtogroup CAPI_SYSTEM_SENSOR_ORIENTATION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an orientation event occurs.
+ *
+ * @remark  All values are angles in degrees.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a azimuth, @a pitch, and @a roll values
+ * @param[in] azimuth       The angle between the magnetic north direction and the y-axis, around the z-axis [0 ~ 359]. \n
+ *                          0 = North, 90 = East, 180 = South, 270 = West
+ * @param[in] pitch         The rotation around x-axis [-180 ~ 180], with positive values when the z-axis moves \n
+ *                          toward the y-axis
+ * @param[in] roll          The rotation around y-axis [-90 ~ 90], with positive values when the x-axis moves \n
+ *                          toward the z-axis
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_orientation_set_cb().
+ * @see sensor_orientation_set_cb()
+ * @see sensor_orientation_unset_cb()
+ */
+typedef void (*sensor_orientation_event_cb)( unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data);
+               
+/**
+ * @brief      Registers a callback function to be invoked when an orientation event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms The interval sensor events are delivered in (in milliseconds) \n
+ *                          If @a interval_ms is zero, it uses default value (100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function 
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_orientation_event_cb() will be invoked.
+ *
+ * @see sensor_orientation_event_cb()
+ * @see sensor_orientation_unset_cb()
+*/
+int sensor_orientation_set_cb(sensor_h sensor, int interval_ms, sensor_orientation_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the orientation callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_orientation_set_cb()
+ */
+int sensor_orientation_unset_cb(sensor_h sensor);
+
+/**
+ * @brief      Registers a callback function to be invoked when the current sensor reading falls outside of a defined normal range.
+ *
+ * @param[in]   sensor     The sensor handle
+ * @param[in]   callback   The callback function to register
+ * @param[in]   user_data  The user data to be passed to the callback function 
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ * @retval      #SENSOR_ERROR_NOT_NEED_CALIBRATION  Sensor doesn't need calibration
+ *
+ * @post sensor_calibration_cb() will be invoked.
+ *
+ * @see sensor_orientation_set_calibration_cb()
+ * @see sensor_orientation_unset_calibration_cb()
+ */
+int sensor_orientation_set_calibration_cb(sensor_h sensor, sensor_calibration_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the orientation calibration callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ * @retval     #SENSOR_ERROR_NOT_NEED_CALIBRATION  Sensor doesn't need calibration
+ *
+ * @see sensor_orientation_set_calibration_cb()
+ */
+int sensor_orientation_unset_calibration_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at orientation measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED        Operation failed
+ *
+ * @see sensor_orientation_set_cb()
+ */
+int sensor_orientation_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief Gets sensor data from the orientation sensor.
+ *
+ * @remark
+ * All values are angles in degrees.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[out]  azimuth     The angle in degrees between the magnetic north direction and the y-axis, \n
+ *                          around the z-axis [0 ~ 359]. 0=North, 90=East, 180=South, 270=West
+ * @param[out]  pitch       The rotation in degrees around x-axis [-180 ~ 180], with positive values when the \n
+ *                          z-axis moves toward the y-axis
+ * @param[out]  roll        The rotation in degrees around y-axis [-90 ~ 90], with positive values when the \n
+ *                          x-axis moves toward the z-axis
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ * @see sensor_start()
+ */
+int sensor_orientation_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *azimuth, float *pitch, float *roll);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_GYROSCOPE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a gyroscope event occurs.
+ *
+ * @remark
+ * Measure the rate of rotation around X, Y and Z axis in radians/second values.
+ * All values is observed by positive value in the counter-clockwise direction.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             Angular speed around the x-axis in degree per second
+ * @param[in] y             Angular speed around the y-axis in degree per second
+ * @param[in] z             Angular speed around the z-axis in degree per second
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_gyroscope_set_cb().
+ * @see sensor_gyroscope_set_cb()
+ * @see sensor_gyroscope_unset_cb()
+ */
+typedef void (*sensor_gyroscope_event_cb)( unsigned long long timestamp,
+               sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data);
+               
+/**
+ * @brief      Registers a callback function to be invoked when a gyroscope event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms The interval sensor events are delivered in (in milliseconds) \n
+ *                          If @a interval_ms is zero, it uses default value (100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post       sensor_gyroscope_event_cb() will be invoked
+ *
+ * @see sensor_gyroscope_event_cb()
+ * @see sensor_gyroscope_unset_cb()
+ */
+int sensor_gyroscope_set_cb(sensor_h sensor, int interval_ms, sensor_gyroscope_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the gyroscope callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see        sensor_gyroscope_set_cb()
+ */
+int sensor_gyroscope_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at gyroscope measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED        Operation failed
+ *
+ * @see sensor_gyroscope_set_cb()
+ */
+int sensor_gyroscope_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief
+ * Gets sensor data from the gyroscope sensor.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[out]  x           The angular speed around the x-axis in degree per second
+ * @param[out]  y           The angular speed around the y-axis in degree per second
+ * @param[out]  z           The angular speed around the z-axis in degree per second
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ * @see        sensor_start()
+ */
+int sensor_gyroscope_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *x, float *y, float *z);
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_LIGHT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a light event occurs.
+ *
+ * @remark
+ * You should use lux between min and max values obtained \n
+ * with #sensor_get_spec().
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] lux           The ambient light level in SI lux units \n
+ *                     @a lux is between min and max values obtained with #sensor_get_spec().\n
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_light_set_cb().
+ * @see sensor_light_set_cb()
+ * @see sensor_light_unset_cb()
+ */
+typedef void (*sensor_light_event_cb)( unsigned long long timestamp, float lux, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a light event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms The interval sensor events are delivered in (in milliseconds) \n
+ *                          If @a interval_ms is zero, it uses default value (100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_light_event_cb() will be invoked.
+ *
+ * @see sensor_light_event_cb()
+ * @see        sensor_light_unset_cb()
+ */
+int sensor_light_set_cb(sensor_h sensor, int interval_ms, sensor_light_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the light callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_light_set_cb()
+ */
+int sensor_light_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at light sensor measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED        Operation failed
+ *
+ * @see sensor_light_set_cb()
+ */
+int sensor_light_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief      Gets sensor data from the light sensor.
+ *
+ * @remark
+ * You should use lux between min and max values obtained \n
+ * with #sensor_get_spec().
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  lux       The ambient light level in SI lux units \n
+ *                     @a lux is between min and max values obtained with #sensor_get_spec().\n
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @pre In order to read sensor data, an application should call sensor_start().
+ * @see #sensor_data_accuracy_e
+ * @see sensor_start()
+ */
+int sensor_light_read_data(sensor_h sensor, float *lux);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_PROXIMITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a proximity event occurs.
+ *
+ * @param[in]  timestamp     The time in nanosecond at which the event ahppened
+ * @param[in]  distance       The distance measured in centemeters
+ * @param[in]  user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_proximity_set_cb().
+ * @see sensor_proximity_set_cb()
+ * @see sensor_proximity_unset_cb()
+ */
+typedef void (*sensor_proximity_event_cb)( unsigned long long timestamp, float distance, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a proximity event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms    The interval sensor events are delivered in (in milliseconds) \n
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_proximity_event_cb() will be invoked.
+ *
+ * @see sensor_proximity_event_cb()
+ * @see sensor_proximity_unset_cb()
+ */
+int sensor_proximity_set_cb(sensor_h sensor, int interval_ms, sensor_proximity_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the proximity callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_proximity_set_cb()
+ */
+int sensor_proximity_unset_cb(sensor_h sensor);
+
+/**
+ * @brief change the interval at proximity measurements.
+ * 
+ * @param[in]   sensor          The sensor handle
+ * @param[in]   interval_ms     in milliseconds.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_proximity_set_cb()
+ */
+int sensor_proximity_set_interval(sensor_h sensor, int interval_ms);
+
+/**
+ * @brief Gets sensor data from the Proximity sensor.
+ *
+ * @remark
+ * All values are angles in degrees.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  distance    The distance measured in centemeters
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ * @see sensor_start()
+ */
+int sensor_proximity_read_data(sensor_h sensor, float *distance);
+
+
+/**
+ * @}
+ *
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_MODULE
+ * @{
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SNAP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a snap motion event occurs.
+ * @image html phone_snap.png
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] snap          The type of motion snap
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_snap_set_cb().
+ * @see sensor_motion_snap_set_cb()
+ * @see sensor_motion_snap_unset_cb()
+ */
+typedef void (*sensor_motion_snap_event_cb) ( unsigned long long timestamp, sensor_motion_snap_e snap, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion snap event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_snap_event_cb() will be invoked.
+ *
+ * @see sensor_motion_snap_event_cb()
+ * @see sensor_motion_snap_unset_cb() 
+ */
+int sensor_motion_snap_set_cb(sensor_h sensor, sensor_motion_snap_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the snap callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_motion_snap_set_cb() 
+ */
+int sensor_motion_snap_unset_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SHAKE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a shake motion event occurs.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] shake         The type of motion shake
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_shake_set_cb().
+ * @see sensor_motion_shake_set_cb()
+ * @see sensor_motion_shake_unset_cb()
+ */
+typedef void (*sensor_motion_shake_event_cb) ( unsigned long long timestamp, sensor_motion_shake_e shake, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion shake event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback       The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_shake_event_cb() will be invoked.
+ *
+ * @see sensor_motion_shake_event_cb()
+ * @see sensor_motion_shake_unset_cb()
+ */
+int sensor_motion_shake_set_cb(sensor_h sensor, sensor_motion_shake_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR             I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_motion_shake_set_cb()
+ */
+int sensor_motion_shake_unset_cb(sensor_h sensor);
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_DOUBLETAP_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a double tap motion event occurs.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_doubletap_set_cb().
+ * @see sensor_motion_doubletap_set_cb()
+ * @see sensor_motion_doubletap_unset_cb()
+ */
+typedef void (*sensor_motion_doubletap_event_cb) ( unsigned long long timestamp, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion doubletap event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_doubletap_event_cb() will be invoked.
+ *
+ * @see sensor_motion_doubletap_event_cb()
+ * @see        sensor_motion_doubletap_unset_cb()
+ */
+int sensor_motion_doubletap_set_cb(sensor_h sensor, sensor_motion_doubletap_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the doubletap callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see        sensor_motion_doubletap_set_cb()
+ */
+int sensor_motion_doubletap_unset_cb(sensor_h sensor);
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_PANNING_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a panning motion event occurs.
+ * @image html phone_panning.png
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] x             1/10 angle on x-axis
+ * @param[in] y             1/10 angle on y-axis
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_panning_set_cb().
+ * @see sensor_motion_panning_set_cb()
+ * @see sensor_motion_panning_unset_cb()
+ */
+typedef void (*sensor_motion_panning_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion panning event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_panning_event_cb() will be invoked.
+ *
+ * @see sensor_motion_panning_event_cb()
+ * @see        sensor_motion_panning_unset_cb()
+ */
+int sensor_motion_panning_set_cb(sensor_h sensor, sensor_motion_panning_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see        sensor_motion_panning_set_cb()
+ */
+int sensor_motion_panning_unset_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_PANNING_BROWSE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a panning browse motion event occurs.
+ * @image html phone_panning.png
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] x             1/10 angle on x-axis
+ * @param[in] y             1/10 angle on y-axis
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_panning_browse_set_cb().
+ * @see sensor_motion_panning_browse_set_cb()
+ * @see sensor_motion_panning_browse_unset_cb()
+ */
+typedef void (*sensor_motion_panning_browse_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion panning browse event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_panning_browse_event_cb() will be invoked.
+ *
+ * @see sensor_motion_panning_browse_event_cb()
+ * @see        sensor_motion_panning_browse_unset_cb()
+ */
+int sensor_motion_panning_browse_set_cb(sensor_h sensor, sensor_motion_panning_browse_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see        sensor_motion_panning_browse_set_cb()
+ */
+int sensor_motion_panning_browse_unset_cb(sensor_h sensor);
+
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_TILT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a tilt motion event occurs.
+ * @image html phone_panning.png
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] x             1/10 angle on x-axis
+ * @param[in] y             1/10 angle on y-axis
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_tilt_set_cb().
+ * @see sensor_motion_tilt_set_cb()
+ * @see sensor_motion_tilt_unset_cb()
+ */
+typedef void (*sensor_motion_tilt_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion tilt event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_tilt_event_cb() will be invoked.
+ *
+ * @see sensor_motion_tilt_event_cb()
+ * @see        sensor_motion_tilt_unset_cb()
+ */
+int sensor_motion_tilt_set_cb(sensor_h sensor, sensor_motion_tilt_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see        sensor_motion_tilt_set_cb()
+ */
+int sensor_motion_tilt_unset_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_FACEDOWN_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a facedown motion event occurs.
+ * @details
+ * This event occurs when device is flipped as follows:
+ * @image html phone_facedown.png
+ * This motion event will fire only when the device is flipped from face to back.
+ * It will not occur when the device is flipped from back to face.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_facedown_set_cb().
+ * @see sensor_motion_facedown_set_cb()
+ * @see sensor_motion_facedown_unset_cb()
+ */
+typedef void (*sensor_motion_facedown_event_cb) ( unsigned long long timestamp, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion facedown event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_facedown_event_cb() will be invoked.
+ *
+ * @see sensor_motion_facedown_event_cb()
+ * @see sensor_motion_facedown_unset_cb()
+ */
+int sensor_motion_facedown_set_cb(sensor_h sensor, sensor_motion_facedown_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the facedown callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_motion_facedown_set_cb()
+ */
+
+int sensor_motion_facedown_unset_cb(sensor_h sensor);
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_DIRECTCALL_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a directcall motion event occurs.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_directcall_set_cb().
+ * @see sensor_motion_directcall_set_cb()
+ * @see sensor_motion_directcall_unset_cb()
+ */
+typedef void (*sensor_motion_directcall_event_cb) ( unsigned long long timestamp, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion directcall event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_directcall_event_cb() will be invoked.
+ *
+ * @see sensor_motion_directcall_event_cb()
+ * @see sensor_motion_directcall_unset_cb()
+ */
+int sensor_motion_directcall_set_cb(sensor_h sensor, sensor_motion_directcall_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the directcall callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_motion_directcall_set_cb()
+ */
+int sensor_motion_directcall_unset_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_SMART_ALERT_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a smart alert motion event occurs.
+ * @details
+ * This event occurs when device is picked up as follows:
+ * @image html phone_smart_alert.png
+ * This motion event will fire only when the device is picked up on desk or etc.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_smart_alert_set_cb().
+ * @see sensor_motion_smart_alert_set_cb()
+ * @see sensor_motion_smart_alert_unset_cb()
+ */
+typedef void (*sensor_motion_smart_alert_event_cb) ( unsigned long long timestamp, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when a motion smart alert event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_smart_alert_event_cb() will be invoked.
+ *
+ * @see sensor_motion_smart_alert_event_cb()
+ * @see sensor_motion_smart_alert_unset_cb()
+ */
+int sensor_motion_smart_alert_set_cb(sensor_h sensor, sensor_motion_smart_alert_event_cb callback, void *user_data);
+
+/**
+ * @brief      Unregister the smart alert callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_motion_smart_alert_set_cb()
+ */
+int sensor_motion_smart_alert_unset_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_MOTION_NO_MOVE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when a no move motion event occurs.
+ * @details
+ * This event occurs when device doesn't move
+ * @image html phone_no_move.png
+ * This motion event will fire only when the device doesn't move at any position during 1 or 2 seconds.
+ *
+ * @param[in] timestamp     The time in nanosecond at which the event ahppened
+ * @param[in] user_data     The user data passed from the callback registration function
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_motion_no_move_set_cb().
+ * @see sensor_motion_no_move_set_cb()
+ * @see sensor_motion_no_move_unset_cb()
+ */
+typedef void (*sensor_motion_no_move_event_cb) ( unsigned long long timestamp, void *user_data);
+
+
+/**
+ * @brief       Registers a callback function to be invoked when a motion no move event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_motion_no_move_event_cb() will be invoked.
+ *
+ * @see sensor_motion_no_move_event_cb()
+ * @see sensor_motion_no_move_unset_cb()
+ */
+int sensor_motion_no_move_set_cb(sensor_h sensor, sensor_motion_no_move_event_cb callback, void *user_data);
+
+
+/**
+ * @brief       Unregister the no move callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                          I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_motion_no_move_set_cb()
+ */
+int sensor_motion_no_move_unset_cb(sensor_h sensor);
+
+
+/**
+ * @}
+ *
+ * @}
+ *
+ * @addtogroup CAPI_SYSTEM_SENSOR_ROTATION_VECTOR_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an rotation vector event occurs.
+ * @details
+ * The values of rotation vector represents orientation of the device as a combination of an angle and an axis.
+ * Each value of the rotation vector is not have unit. the x,y,z axis is same unit as accelerometer.
+ *
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             x*sin(θ/2)
+ * @param[in] y             y*sin(θ/2)
+ * @param[in] z             z*sin(θ/2)
+ * @param[in] w             cos(θ/2)
+ * @param[in] user_data     The user data passed from the callback registration function
+ *
+ * @pre sensor_start() will invoke this callback if you register this callback using sensor_rotation_vector_set_cb().
+ *
+ * @see sensor_rotation_vector_set_cb()
+ * @see sensor_rotation_vector_unset_cb()
+ */
+typedef void (*sensor_rotation_vector_event_cb)(
+               sensor_data_accuracy_e accuracy, float x, float y, float z, float w, void *user_data);
+
+/**
+ * @brief      Registers a callback function to be invoked when an rotation vector event occurs.
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[in]   interval_ms    The interval sensor events are delivered at (in milliseconds) \n
+ *                                                     If @a rate is zero, it uses default value(100ms)
+ * @param[in]   callback    The callback function to register
+ * @param[in]   user_data   The user data to be passed to the callback function
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR              I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @post sensor_accelerometer_event_cb() will be invoked.
+ *
+ * @see sensor_accelerometer_event_cb()
+ * @see sensor_accelerometer_unset_cb()
+ */
+int sensor_rotation_vector_set_cb(sensor_h sensor, int interval_ms, sensor_rotation_vector_event_cb callback, void* user_data);
+
+/**
+ * @brief      Unregister the rotation vector callback function.
+ *
+ * @param[in]   sensor     The sensor handle
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                    Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                I/O error
+ * @retval      #SENSOR_ERROR_OPERATION_FAILED      Operation failed
+ *
+ * @see sensor_rotation_vector_set_cb()
+ */
+int sensor_rotation_vector_unset_cb(sensor_h sensor);
+
+/**
+ * @brief      Gets sensor data from the rotation vector sensor.
+ * 
+ * @details
+ * The rotation vector sensor retrieves quaternion elements <cos(θ/2), x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)>. \n
+ * Last three elements of the quaternion represents rotation vector. \n
+ * Each axis value of rotation vector is composed of the angle from magnitude equal to sin(θ/2) and the axis. \n
+ * The value of rotation vector in each axis don't have unit. the axis x,y and z have same unit as the acceleration sensor.
+ * 
+ * 
+ *
+ * @param[in]   sensor      The sensor handle
+ * @param[out]  accuracy    The accuracy of this data
+ * @param[in] x             x*sin(θ/2)
+ * @param[in] y             y*sin(θ/2)
+ * @param[in] z             z*sin(θ/2)
+ * @param[in] w             cos(θ/2)
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval      #SENSOR_ERROR_IO_ERROR                         I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ */
+int sensor_rotation_vector_read_data(sensor_h sensor, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z, float* w);
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup CAPI_SYSTEM_SENSOR_UTILITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief      Enumerations of Axis used in #sensor_util_remap_coordinate_system 
+ *
+ * @see #sensor_util_remap_coordinate_system
+ */
+typedef enum
+{
+    sensor_util_axis_minus_x,
+    sensor_util_axis_minus_y,
+    sensor_util_axis_minus_z,
+    sensor_util_axis_x,
+    sensor_util_axis_y,
+    sensor_util_axis_z,
+} sensor_util_axis_e;
+/**
+ * @}
+ */
+
+/**
+ * @brief
+ * Getting Inclination matrix "I" and Rotation matrix "R" transforming a vector from the device coordinate to the world's coordinate.
+ * 
+ * @details
+ * [0 0 g] = R * gravity (g = magnitude of gravity) \n
+ * [0 m 0] = I * R * geomagnetic (m = magnitude of geomagnetic field) \n
+ * R is the identity matrix when the device is aligned with the world's coordinate system, that is, when the device's X axis points toward East, the Y axis points to the North Pole and the device is facing the sky. \n
+ * I is a rotation matrix transforming the geomagnetic vector into the same coordinate space as gravity (the world's coordinate space). I is a simple rotation around the X axis. \n
+ *
+ * @remark
+ * Parameter Gx, Gy, Gz can be got from the values returned by a #sensor_gravity_event_cb or #sensor_gravity_read_data. \n
+ * Parameter Mx, My, Mz can be got from the values returned by a #sensor_magnetic_event_cb or #sensor_magnetic_read_data.
+ * Output parameter R and I is always returned 3x3 matrix array of 9 floats like this form:
+ * <pre>
+ * { R[0], R[1], R[2],
+ *   R[3], R[4], R[5],
+ *   R[6], R[7], R[6] }
+ * </pre>
+ * 
+ * 
+ * @param[in]  Gx   X-axis gravity vector in the device's coordinate. 
+ * @param[in]  Gy   Y-axis gravity vector in the device's coordinate. 
+ * @param[in]  Gz   Z-axis gravity vector in the device's coordinate. 
+ * @param[in]  Mx   X-axis geomagnetic vector in the device's coordinate. 
+ * @param[in]  My   Y-axis geomagnetic vector in the device's coordinate. 
+ * @param[in]  Mz   Z-axis geomagnetic vector in the device's coordinate. 
+ * @param[out] R    Array of 9 floats that represents the rotation matrix "R". It can be null.
+ * @param[out] I    Array of 9 floats that represents the inclination matrix "I". It can be null.
+ * 
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+int sensor_util_get_rotation_matrix(float Gx, float Gy, float Gz, 
+        float Mx, float My, float Mz,
+        float R[], float I[]);
+
+/**
+ * @brief
+ * Convert a rotation vector to a rotation matrix. 
+ *
+ * @details
+ * rotation vectors (Vx, Vy, Vz) can be got from #sensor_rotation_vector_event_cb or #sensor_rotation_vector_read_data.
+ * It returns a 9 elements rotation matrix in the array R. R must have langth 9.
+ *
+ * @param[in]  Vx   X-axis rotation vector.
+ * @param[in]  Vy   Y-axis rotation vector.
+ * @param[in]  Vz   Z-axis rotation vector.
+ * @param[out] R    A 9 elements ration matrix in the array R that must have length 9.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * 
+ * @see sensor_util_rotation_matrix3
+ * @see sensor_util_rotation_matrix4
+ */
+int sensor_util_get_rotation_matrix_from_vector(float Vx, float Vy, float Vz, float R[]);
+
+/**
+ * @brief
+ * Rotates the supplied rotation matrix so it is expressed in a different coordinate system.
+ *
+ * @details
+ * This is typically used when an application needs to compute the three orientation angles of the device in a different coordinate system.
+ * 
+ * @remark
+ * inR and outR can be the same array, but it is not recommended for performance reason.
+ * Return error when X and Y defines the same axis.
+ *
+ * @param[in]  inR  the rotation matrix (3x3) to be transformed. Usually it is the matrix returned by get #sensor_util_rotation_matrix3 or #sensor_util_rotation_matrix4.
+ * @param[in]  x    defines on which world axis and direction the X axis of the device is mapped.
+ * @param[in]  y    defines on which world axis and direction the Y axis of the device is mapped.
+ * @param[out] outR the transformed rotation matrix (3x3).
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ * 
+ * @see sensor_util_rotation_matrix3
+ * @see sensor_util_rotation_matrix4
+ * @see sensor_util_rotation_matrix_from_vector
+ * @see sensor_util_rotation_matrix_from_quaternion
+ */
+int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[]);
+
+/**
+ * @brief
+ * Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by #sensor_util_get_rotation_matrix()
+ *
+ * @param[in]  I            inclination matrix from #sensor_util_get_rotation_matrix()
+ * @param[out] inclination  The geomagnetic inclination angle in radians.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ *
+ * @see sensor_util_get_rotation_matrix()
+ */
+int sensor_util_get_inclination(float I[], float* inclination); 
+
+/**
+ * @brief
+ * Compute the device's orientation based on the rotation matrix
+ *
+ * @details
+ * When it returns, they array values is filled with the result:
+ *  - values[0]: azimuth, rotation around the Z axis.
+ *  - values[1]: pitch, rotation around the X axis.
+ *  - values[2]: roll, rotation around the Y axis.
+ *
+ * @remark
+ * Parameter R must be array of 9 floats from #sensor_util_get_rotation_matrix() \n
+ * Returned values are always array of 3 floats.
+ * 
+ *
+ * @param[in]     R         A 9 elements ration matrix in the array.
+ * @param[values] values    An array of 3 floats to hold the result.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ *
+ * @see sensor_util_get_rotation_matrix()
+ *
+ */
+int sensor_util_get_orientation(float R[], float values[]);
+
+/**
+ * @brief
+ * Helper function to compute the angle change between two rotation matrices. 
+ *
+ * @details
+ * Given a current rotation matrix (R) and a previous rotation matrix (prevR) computes 
+ * the rotation around the x,y, and z axes which transforms prevR to R. 
+ * outputs a 3 element vector containing the x,y, and z angle change at indexes 0, 1, and 2 respectively. \n
+ *
+ * @remark
+ * Each input matrix is 3x3 matrix like this form:
+ * <pre>
+ * { R[0], R[1], R[2],
+ *   R[3], R[4], R[5],
+ *   R[6], R[7], R[6] }
+ * </pre>
+ * 
+ * @param[in] R             current rotation matrix
+ * @param[in] prevR         previous rotation matrix
+ * @param[out] angleChange  an array of floats in which the angle change is stored
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+int sensor_util_get_angle_change(float R[], float prevR[], float angleChange[]);
+
+/**
+ * @brief
+ * Getting the declination of the horizontal component of the magnetic field from true north, in degrees
+ *
+ * @param[in]  latitude     Latitude in geodetic coordinates 
+ * @param[in]  longitude    Longitude in geodetic coordinates
+ * @param[in]  altitude     Altitude in geodetic coordinates
+ * @param[out] declination  The declination of the horizontal component of the magnetic field in degrees.
+ *
+ * @return      0 on success, otherwise a negative error value
+ * @retval      #SENSOR_ERROR_NONE                  Successful
+ * @retval      #SENSOR_ERROR_INVALID_PARAMETER     Invalid parameter
+ */
+int sensor_util_get_declination(float latitude, float longitude, float altitude, float* declination);
+
+/**
+ * @brief Determines whether or not to be near from proximity sensor's distance value.
+ * 
+ * @remark
+ * This function can be used to determine the proximity to device from other object like human face.
+ *
+ * @param[in] distance      Distance in centimeter from proximity sensor.
+ * @param[out] is_near      proximity to device from other object.
+ */
+int sensor_util_is_near(float distance, bool *is_near);
+
+/**
+ * @brief Continues to sense even when LCD is off
+ * 
+ * @param[in]  sensor    The sensor handle 
+ * @param[out] type      The sensor type 
+ */
+int sensor_set_always_on(sensor_h sensor, sensor_type_e type);
+/**
+ * @}
+ */
+
+
+/**
+ *
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/packaging/capi-system-sensor.spec b/packaging/capi-system-sensor.spec
new file mode 100644 (file)
index 0000000..d513d22
--- /dev/null
@@ -0,0 +1,59 @@
+Name:       capi-system-sensor
+Summary:    A Sensor library in TIZEN C API
+Version: 0.1.17
+Release:    10
+Group:      TO_BE/FILLED_IN
+License:    Apache 2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(sensor)
+BuildRequires:  pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig  
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary:  A Sensor library in TIZEN C API (Development)
+Group:    TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-system-sensor.manifest
+%{_libdir}/libcapi-system-sensor.so.*
+
+%files devel
+%{_includedir}/system/sensors.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-system-sensor.so
+/usr/share/license/%{name}
+
diff --git a/phone_facedown.png b/phone_facedown.png
new file mode 100755 (executable)
index 0000000..5a28ed3
Binary files /dev/null and b/phone_facedown.png differ
diff --git a/phone_panning.png b/phone_panning.png
new file mode 100755 (executable)
index 0000000..d6f6f39
Binary files /dev/null and b/phone_panning.png differ
diff --git a/phone_snap.png b/phone_snap.png
new file mode 100755 (executable)
index 0000000..bc239d5
Binary files /dev/null and b/phone_snap.png differ
diff --git a/src/fusion_util.c b/src/fusion_util.c
new file mode 100644 (file)
index 0000000..119bb1e
--- /dev/null
@@ -0,0 +1,185 @@
+#include <math.h>
+#include <stdlib.h>
+
+float clamp(float v)
+{
+       return (v < 0) ? 0.0 : v;
+}
+
+int getAngleChange(float *R, float *prevR, float *angleChange)
+{
+       if(R == NULL || prevR == NULL || angleChange == NULL)
+               return -1;
+
+       float rd1=0,rd4=0, rd6=0,rd7=0, rd8=0;
+       float ri0=0,ri1=0,ri2=0,ri3=0,ri4=0,ri5=0,ri6=0,ri7=0,ri8=0;
+       float pri0=0, pri1=0, pri2=0, pri3=0, pri4=0, pri5=0, pri6=0, pri7=0, pri8=0;
+
+       ri0 = R[0];
+       ri1 = R[1];
+       ri2 = R[2];
+       ri3 = R[3];
+       ri4 = R[4];
+       ri5 = R[5];
+       ri6 = R[6];
+       ri7 = R[7];
+       ri8 = R[8];
+
+       pri0 = prevR[0];
+       pri1 = prevR[1];
+       pri2 = prevR[2];
+       pri3 = prevR[3];
+       pri4 = prevR[4];
+       pri5 = prevR[5];
+       pri6 = prevR[6];
+       pri7 = prevR[7];
+       pri8 = prevR[8];
+
+       rd1 = pri0 * ri1 + pri3 * ri4 + pri6 * ri7;
+       rd4 = pri1 * ri1 + pri4 * ri4 + pri7 * ri7;
+       rd6 = pri2 * ri0 + pri5 * ri3 + pri8 * ri6;
+       rd7 = pri2 * ri1 + pri5 * ri4 + pri8 * ri7;
+       rd8 = pri2 * ri2 + pri5 * ri5 + pri8 * ri8;
+
+       angleChange[0] = atan2(rd1, rd4);
+       angleChange[1] = asin(-rd7);
+       angleChange[2] = atan2(-rd6, rd8);
+
+       return 0;
+}
+int quatToMatrix(float *quat, float *R)
+{
+       if(quat == NULL || R == NULL)
+               return -1;
+
+       float q0 = quat[0];
+       float q1 = quat[1];
+       float q2 = quat[2];
+       float q3 = quat[3];
+
+       float sq_q1 = 2 * q1 * q1;
+       float sq_q2 = 2 * q2 * q2;
+       float sq_q3 = 2 * q3 * q3;
+       float q1_q2 = 2 * q1 * q2;
+       float q3_q0 = 2 * q3 * q0;
+       float q1_q3 = 2 * q1 * q3;
+       float q2_q0 = 2 * q2 * q0;
+       float q2_q3 = 2 * q2 * q3;
+       float q1_q0 = 2 * q1 * q0;
+
+       R[0] = 1 - sq_q2 - sq_q3;
+       R[1] = q1_q2 - q3_q0;
+       R[2] = q1_q3 + q2_q0;
+       R[3] = q1_q2 + q3_q0;
+       R[4] = 1 - sq_q1 - sq_q3;
+       R[5] = q2_q3 - q1_q0;
+       R[6] = q1_q3 - q2_q0;
+       R[7] = q2_q3 + q1_q0;
+       R[8] = 1 - sq_q1 - sq_q2;
+
+       return 0;
+}
+
+int matrixToQuat(float *mat, float *q)
+{
+       if(q == NULL || mat == NULL)
+               return -1;
+
+       const float Hx = mat[0];
+       const float My = mat[4];
+       const float Az = mat[8];
+       q[0] = sqrtf( clamp( Hx - My - Az + 1) * 0.25f );
+       q[1] = sqrtf( clamp(-Hx + My - Az + 1) * 0.25f );
+       q[2] = sqrtf( clamp(-Hx - My + Az + 1) * 0.25f );
+       q[3]= sqrtf( clamp( Hx + My + Az + 1) * 0.25f );
+       q[0] = copysignf(q[0], mat[7] - mat[5]);
+       q[1] = copysignf(q[1], mat[2] - mat[6]);
+       q[2] = copysignf(q[2], mat[3] - mat[1]);
+
+       return 0;
+}
+
+int getRotationMatrix(float *accel, float *geo, float *R, float *I)
+{
+       if(accel == NULL || geo == NULL || R == NULL || I == NULL)
+               return -1;
+
+       float Ax = accel[0];
+       float Ay = accel[1];
+       float Az = accel[2];
+       float Ex = geo[0];
+       float Ey = geo[1];
+       float Ez = geo[2];
+       float Hx = Ey*Az - Ez*Ay;
+       float Hy = Ez*Ax - Ex*Az;
+       float Hz = Ex*Ay - Ey*Ax;
+       float normH =  (float)sqrt(Hx*Hx + Hy*Hy + Hz*Hz);
+       if(normH < 0.1f){
+               return -1;
+       }
+       float invH = 1.0f / normH;
+       Hx *= invH;
+       Hy *= invH;
+       Hz *= invH;
+       float invA = 1.0f / (float)sqrt(Ax*Ax + Ay*Ay + Az*Az);
+       Ax *= invA;
+       Ay *= invA;
+       Az *= invA;
+       float Mx = Ay*Hz - Az*Hy;
+       float My = Az*Hx - Ax*Hz;
+       float Mz = Ax*Hy - Ay*Hx;
+
+       R[0] = Hx;  R[1] = Hy;  R[2] = Hz;
+       R[3] = Mx;  R[4] = My;  R[5] = Mz;
+       R[6] = Ax;  R[7] = Ay;  R[8] = Az;
+
+       float invE = 1.0 / (float)sqrt(Ex*Ex + Ey*Ey + Ez*Ez);
+       float c = (Ex*Mx + Ey*My + Ez*Mz) * invE;
+       float s = (Ex*Ax + Ey*Ay + Ez*Az) * invE;
+
+       I[0] = 1;     I[1] = 0;     I[2] = 0;
+       I[3] = 0;     I[4] = c;     I[5] = s;
+       I[6] = 0;     I[7] =-s;     I[8] = c;
+
+       return 0;
+}
+
+
+int remapCoordinateSystem(float *inR, int X, int Y, float *outR)
+{
+       if(inR == NULL || outR == NULL)
+               return -1;
+
+       if ((X & 0x7C)!=0 || (Y & 0x7C)!=0)
+               return -1;   // invalid parameter
+       if (((X & 0x3)==0) || ((Y & 0x3)==0))
+               return -1;   // no axis specified
+       if ((X & 0x3) == (Y & 0x3))
+               return -1;   // same axis specified
+
+       int Z = X ^ Y;
+       int x = (X & 0x3)-1;
+       int y = (Y & 0x3)-1;
+       int z = (Z & 0x3)-1;
+
+       int axis_y = (z+1)%3;
+       int axis_z = (z+2)%3;
+       if (((x^axis_y)|(y^axis_z)) != 0)
+               Z ^= 0x80;
+
+       char sx = (X>=0x80) ? 1 : 0;
+       char sy = (Y>=0x80) ? 1 : 0;
+       char sz = (Z>=0x80) ? 1 : 0;
+
+       int i = 0 , j = 0;
+       for (j=0 ; j<3 ; j++) {
+               int offset = j*3;
+               for (i=0 ; i<3 ; i++) {
+                       if (x==i)   outR[offset+i] = sx ? -inR[offset+0] : inR[offset+0];
+                       if (y==i)   outR[offset+i] = sy ? -inR[offset+1] : inR[offset+1];
+                       if (z==i)   outR[offset+i] = sz ? -inR[offset+2] : inR[offset+2];
+               }
+       }
+       return 0;
+}
+
diff --git a/src/geomanetic_field.c b/src/geomanetic_field.c
new file mode 100755 (executable)
index 0000000..7be8ba7
--- /dev/null
@@ -0,0 +1,274 @@
+#include <math.h>\r
+#include <stdlib.h>\r
+\r
+const float c[13][13] = {\r
+       {0.0, -29496.6, -3594.9, 3350.2, 3992.6, -1818.3, 1051.0, 2158.4, 1226.7, 512.8, -360.9, 1033.3, -1452.4, },\r
+       {4944.4, -1586.3, 5241.4, -7122.5, 4476.4, 3631.5, 1296.8, -2663.8, 543.0, 1197.6, -1532.7, -699.6, -179.4, },\r
+       {-4689.9, -498.9, 1445.0, 2385.6, 652.3, 1539.3, 1135.8, -136.1, -813.2, 369.4, 189.6, -859.0, 238.5, },\r
+       {-490.5, 487.8, -424.2, 501.2, -746.9, -664.0, -1408.7, 927.7, -231.9, -431.5, -181.8, 557.5, 649.2, },\r
+       {1584.9, -826.5, 343.7, -228.6, 66.1, -361.6, -124.4, 171.7, -516.0, 174.8, -23.4, -119.8, -292.1, },\r
+       {453.4, 1451.7, -556.3, 0.0, 70.8, -5.5, 30.7, 64.2, 170.6, -417.8, 184.8, 79.2, 300.6, },\r
+       {-393.2, 659.0, 612.7, -361.8, 7.2, 36.9, -52.3, 4.1, 74.8, -12.2, -12.4, -75.3, -20.8, },\r
+       {-2053.7, -611.1, 133.1, 307.5, 43.2, -67.1, -2.1, 3.2, -35.3, 63.3, 44.1, 19.8, 58.5, },\r
+       {737.3, -1121.6, 492.9, -465.2, 247.7, 48.1, -27.1, 1.1, -2.3, -22.0, 25.4, 41.0, -23.4, },\r
+       {-2611.8, 1249.5, 1062.2, -405.9, -249.3, 139.2, 15.8, -15.8, 4.3, -6.2, -2.7, 0.9, -10.2, },\r
+       {681.2, -21.1, 776.8, 514.2, -532.2, -41.3, -78.2, -16.4, -5.3, -4.9, -1.7, 1.9, 1.9, },\r
+       {93.3, 695.4, -196.8, -431.1, 142.6, -37.6, -124.0, -29.6, -18.5, -5.2, -1.0, 2.2, -2.2, },\r
+       {-807.3, 238.5, 1363.4, -1217.3, 167.0, 125.0, 0.0, 5.9, 7.7, -8.5, -0.6, 0.5, 0.0, }};\r
+\r
+\r
+const float cd[13][13] = {\r
+       {0.0, 11.6, -18.1, 1.0, -7.9, -7.9, -2.9, 2.7, -5.0, 0.0, 0.0, 0.0, 0.0, },\r
+       {-25.9, 16.5, -7.6, -12.6, 12.7, 6.1, -3.8, -3.5, 6.7, -12.7, 0.0, 0.0, 0.0, },\r
+       {-39.0, -10.2, 1.6, -5.6, -34.0, -13.8, -1.5, -17.4, -33.6, 0.0, -21.1, 0.0, 79.5, },\r
+       {22.4, -7.6, -2.1, -6.1, 9.6, -4.7, 19.9, 26.6, 8.3, 24.9, 33.1, 32.8, 64.9, },\r
+       {6.1, 10.6, 8.2, -0.6, -1.6, 2.0, -9.3, 4.9, -5.3, -22.6, 0.0, 0.0, -48.7, },\r
+       {4.1, 13.8, 5.6, 8.9, -0.4, 0.7, -0.7, 1.9, 4.4, -10.1, -7.4, 0.0, 0.0, },\r
+       {-3.8, -31.4, -4.0, -3.3, 1.2, 0.6, 1.1, -1.7, 2.1, 1.7, -8.3, 0.0, 0.0, },\r
+       {24.8, 8.7, -2.0, -1.2, -4.9, -0.7, 0.2, 0.4, -1.5, -0.8, 0.0, 0.0, 0.0, },\r
+       {-6.7, 11.2, 16.6, 10.7, 1.5, -0.7, 1.0, 0.2, 0.1, -1.0, -0.8, 0.0, 0.0, },\r
+       {0.0, -21.7, 0.0, -5.6, 3.4, 0.0, -1.5, 0.8, 0.1, -0.1, -0.5, 0.0, 0.0, },\r
+       {24.3, -21.1, 0.0, -11.7, -7.4, 0.0, -2.0, -1.6, 0.0, -0.1, -0.1, -0.3, 0.0, },\r
+       {0.0, 40.9, 0.0, 24.0, 0.0, 9.4, 0.0, -2.3, -0.9, 0.0, -0.1, 0.0, -0.3, },\r
+       {0.0, 0.0, 0.0, 0.0, 0.0, 20.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, }};\r
+\r
+float g_declination = 0;\r
+float g_inclination = 0;\r
+\r
+static void E0000(int IENTRY, int maxdeg, float alt,float glat,float glon, float time, float *dec, float *dip, float *ti, float *gv);\r
+\r
+int getDeclination(float *decl)\r
+{\r
+       if(decl == NULL)\r
+               return -1;\r
+       \r
+       *decl = g_declination;\r
+\r
+       return 0;\r
+}\r
+\r
+int getInclination(float *incl)\r
+{\r
+        if(incl == NULL)\r
+                return -1;\r
+\r
+        *incl = g_inclination;\r
+\r
+        return 0;\r
+}\r
+\r
+int setCoordinate(float latitude, float longitude, float altitude, float *declination, float *inclination, int option)\r
+{\r
+       float dec, dip, ti, gv;\r
+       float h;\r
+       float rTd=0.017453292;\r
+       \r
+       E0000(0,12,0.0,0.0,0.0,0.0,NULL,NULL,NULL,NULL);\r
+       E0000(1,0,altitude,latitude,longitude,2,&dec,&dip,&ti,&gv);\r
+\r
+       h=ti*(cos((dip*rTd)));\r
+\r
+       /* deal with geographic and magnetic poles */\r
+\r
+       if (h < 100.0) /* at magnetic poles */\r
+       {\r
+               dec = 0;\r
+       }\r
+\r
+       if(option == 1)\r
+       {\r
+               if(declination != NULL)\r
+                       *declination = dec;\r
+               if(inclination != NULL)\r
+                       *inclination = dip;\r
+       }\r
+       else if( option == 0)\r
+       {\r
+               g_declination = dec;\r
+               g_inclination = dip;\r
+       }\r
+\r
+       return 0;\r
+}\r
+/*************************************************************************/\r
+\r
+static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv)\r
+{\r
+       static int maxord,n,m,j,D1,D2,D3,D4;\r
+       static float tc[13][13],dp[13][13],snorm[169],\r
+                     sp[13],cp[13],fn[13],fm[13],pp[13],k[13][13],pi,dtr,a,b,re,\r
+                     a2,b2,c2,a4,b4,c4,flnmj,otime,oalt,\r
+                     olat,olon,dt,rlon,rlat,srlon,srlat,crlon,crlat,srlat2,\r
+                     crlat2,q,q1,q2,ct,st,r2,r,d,ca,sa,aor,ar,br,bt,bp,bpp,\r
+                     par,temp1,temp2,parp,bx,by,bz,bh;\r
+       static float *p = snorm;\r
+\r
+       switch(IENTRY){case 0: goto GEOMAG; case 1: goto GEOMG1;}\r
+\r
+GEOMAG:\r
+       maxord = 12;\r
+       sp[0] = 0.0;\r
+       cp[0] = *p = pp[0] = 1.0;\r
+       dp[0][0] = 0.0;\r
+       a = 6378.137;\r
+       b = 6356.7523142;\r
+       re = 6371.2;\r
+       a2 = a*a;\r
+       b2 = b*b;\r
+       c2 = a2-b2;\r
+       a4 = a2*a2;\r
+       b4 = b2*b2;\r
+       c4 = a4 - b4;\r
+\r
+       *snorm = 1.0;\r
+       fm[0] = 0.0;\r
+       for (n=1; n<=maxord; n++)\r
+       {\r
+               *(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n;\r
+               j = 2;\r
+               for (m=0,D1=1,D2=(n-m+D1)/D1; D2>0; D2--,m+=D1)\r
+               {\r
+                       k[m][n] = (float)(((n-1)*(n-1))-(m*m))/(float)((2*n-1)*(2*n-3));\r
+                       if (m > 0)\r
+                       {\r
+                               flnmj = (float)((n-m+1)*j)/(float)(n+m);\r
+                               *(snorm+n+m*13) = *(snorm+n+(m-1)*13)*sqrt(flnmj);\r
+                               j = 1;\r
+                       }\r
+               }\r
+               fn[n] = (float)(n+1);\r
+               fm[n] = (float)n;\r
+       }\r
+       k[1][1] = 0.0;\r
+\r
+       otime = oalt = olat = olon = -1000.0;\r
+       \r
+       return;\r
+\r
+       /*************************************************************************/\r
+\r
+GEOMG1:\r
+\r
+       dt = time;\r
+       pi = 3.14159265359;\r
+       dtr = pi/180.0;\r
+       rlon = glon*dtr;\r
+       rlat = glat*dtr;\r
+       srlon = sin(rlon);\r
+       srlat = sin(rlat);\r
+       crlon = cos(rlon);\r
+       crlat = cos(rlat);\r
+       srlat2 = srlat*srlat;\r
+       crlat2 = crlat*crlat;\r
+       sp[1] = srlon;\r
+       cp[1] = crlon;\r
+\r
+       if (alt != oalt || glat != olat)\r
+       {\r
+               q = sqrt(a2-c2*srlat2);\r
+               q1 = alt*q;\r
+               q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));\r
+               ct = srlat/sqrt(q2*crlat2+srlat2);\r
+               st = sqrt(1.0-(ct*ct));\r
+               r2 = (alt*alt)+2.0*q1+(a4-c4*srlat2)/(q*q);\r
+               r = sqrt(r2);\r
+               d = sqrt(a2*crlat2+b2*srlat2);\r
+               ca = (alt+d)/r;\r
+               sa = c2*crlat*srlat/(r*d);\r
+       }\r
+       if (glon != olon)\r
+       {\r
+               for (m=2; m<=maxord; m++)\r
+               {\r
+                       sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];\r
+                       cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];\r
+               }\r
+       }\r
+       aor = re/r;\r
+       ar = aor*aor;\r
+       br = bt = bp = bpp = 0.0;\r
+       for (n=1; n<=maxord; n++)\r
+       {\r
+               ar = ar*aor;\r
+               for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3)\r
+               {\r
+                       if (alt != oalt || glat != olat)\r
+                       {\r
+                               if (n == m)\r
+                               {\r
+                                       *(p+n+m*13) = st**(p+n-1+(m-1)*13);\r
+                                       dp[m][n] = st*dp[m-1][n-1]+ct**(p+n-1+(m-1)*13);\r
+                                       goto S50;\r
+                               }\r
+                               if (n == 1 && m == 0)\r
+                               {\r
+                                       *(p+n+m*13) = ct**(p+n-1+m*13);\r
+                                       dp[m][n] = ct*dp[m][n-1]-st**(p+n-1+m*13);\r
+                                       goto S50;\r
+                               }\r
+                               if (n > 1 && n != m)\r
+                               {\r
+                                       if (m > n-2) *(p+n-2+m*13) = 0.0;\r
+                                       if (m > n-2) dp[m][n-2] = 0.0;\r
+                                       *(p+n+m*13) = ct**(p+n-1+m*13)-k[m][n]**(p+n-2+m*13);\r
+                                       dp[m][n] = ct*dp[m][n-1] - st**(p+n-1+m*13)-k[m][n]*dp[m][n-2];\r
+                               }\r
+                       }\r
+S50:\r
+                       if (time != otime)\r
+                       {\r
+                               tc[m][n] = c[m][n]+dt*cd[m][n];\r
+                               if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];\r
+                       }\r
+                       \r
+                       par = ar**(p+n+m*13);\r
+                       if (m == 0)\r
+                       {\r
+                               temp1 = tc[m][n]*cp[m];\r
+                               temp2 = tc[m][n]*sp[m];\r
+                       }\r
+                       else\r
+                       {\r
+                               temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];\r
+                               temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];\r
+                       }\r
+                       bt = bt-ar*temp1*dp[m][n];\r
+                       bp += (fm[m]*temp2*par);\r
+                       br += (fn[n]*temp1*par);\r
+                       \r
+                       if (st == 0.0 && m == 1)\r
+                       {\r
+                               if (n == 1) pp[n] = pp[n-1];\r
+                               else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];\r
+                               parp = ar*pp[n];\r
+                               bpp += (fm[m]*temp2*parp);\r
+                       }\r
+               }\r
+       }\r
+       if (st == 0.0) bp = bpp;\r
+       else bp /= st;\r
+       \r
+       bx = -bt*ca-br*sa;\r
+       by = bp;\r
+       bz = bt*sa-br*ca;\r
+       bh = sqrt((bx*bx)+(by*by));\r
+       *ti = sqrt((bh*bh)+(bz*bz));\r
+       *dec = atan2(by,bx)/dtr;\r
+       *dip = atan2(bz,bh)/dtr;\r
+       *gv = -999.0;\r
+       if (fabs(glat) >= 55.)\r
+       {\r
+               if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;\r
+               if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);\r
+               if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;\r
+               if (glat < 0.0 && glon < 0.0) *gv = *dec-fabs(glon);\r
+               if (*gv > +180.0) *gv -= 360.0;\r
+               if (*gv < -180.0) *gv += 360.0;\r
+       }\r
+       otime = time;\r
+       oalt = alt;\r
+       olat = glat;\r
+       olon = glon;\r
+       return;\r
+}\r
+\r
diff --git a/src/sensor.c b/src/sensor.c
new file mode 100644 (file)
index 0000000..5133938
--- /dev/null
@@ -0,0 +1,1517 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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. 
+ */
+
+
+
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include <sensor.h>
+#include <sensor_accel.h>
+#include <sensor_geomag.h>
+#include <sensor_light.h>
+#include <sensor_proxi.h>
+#include <sensor_motion.h>
+#include <sensor_gyro.h>
+#include <sensors.h>
+#include <sensor_private.h>
+#include <dlog.h>
+
+#define _DEBUG 1
+
+#ifdef _DEBUG
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_SYSTEM_SENSOR"
+#include <stdio.h>
+#include <libgen.h>
+static char* _DONT_USE_THIS_ARRAY_DIRECTLY[] = {
+       "ACCELEROMETER",
+       "GRAVITY",
+       "LINEAR_ACCELERATION",
+       "DEVICE_ORIENTATION",
+       "MAGNETIC",
+       "ORIENTATION",
+       "GYROSCOPE",
+       "LIGHT",
+       "PROXIMITY",
+       "MOTION_SNAP",
+       "MOTION_SHAKE",
+       "MOTION_DOUBLETAP",
+       "MOTION_PANNING",
+       "MOTION_PANNING_BROWSE",
+       "MOTION_TILT",
+       "MOTION_FACEDOWN",
+       "MOTION_DIRECTCALL",
+       "MOTION_SMART_ALERT",
+       "MOTION_NO_MOVE",
+       "LAST"
+};
+
+#define _MSG_SENSOR_ERROR_IO_ERROR "Io Error"
+#define _MSG_SENSOR_ERROR_INVALID_PARAMETER "Invalid Parameter"
+#define _MSG_SENSOR_ERROR_OUT_OF_MEMORY "Out of Memory"
+#define _MSG_SENSOR_ERROR_NOT_NEED_CALIBRATION "Not need calibration"
+#define _MSG_SENSOR_ERROR_NOT_SUPPORTED "Not supported"
+#define _MSG_SENSOR_ERROR_OPERATION_FAILED "Operation failed"
+
+#define TYPE_NAME(type) _DONT_USE_THIS_ARRAY_DIRECTLY[type]
+
+#define DEBUG_PRINT(txt) LOGD("%s : " txt, __FUNCTION__)
+#define DEBUG_PRINTF(fmt, ...) LOGD("%s : " fmt, __FUNCTION__, __VA_ARGS__)
+#define ERROR_PRINT(err) LOGD("[%s]" _MSG_##err "(0x%08x)", __FUNCTION__, err)
+#define ERROR_PRINTF(err, fmt, ...) LOGD("[%s]" _MSG_##err "(0x%08x) : " fmt, __FUNCTION__, err, __VA_ARGS__)
+#else
+#define TYPE_NAME(type) ""
+#define DEBUG_PRINT(txt)
+#define DEBUG_PRINTF(fmt, ...)
+#define ERROR_PRINT(err)
+#define ERROR_PRINTF(err)
+#endif
+
+#define RETURN_VAL_IF(expr, err) \
+       do { \
+               if (expr) { \
+                       ERROR_PRINT(err); \
+                       return (err); \
+               } \
+       } while(0)
+
+#define RETURN_ERROR(err) \
+       do { \
+               ERROR_PRINT(err); \
+               return err; \
+       } while(0)
+
+
+#define RETURN_IF_NOT_HANDLE(handle) \
+       RETURN_VAL_IF(handle == NULL, SENSOR_ERROR_INVALID_PARAMETER)
+
+#define RETURN_IF_NOT_TYPE(type) \
+       RETURN_VAL_IF(type >= SENSOR_LAST || type < 0, SENSOR_ERROR_INVALID_PARAMETER)
+
+#define RETURN_IF_MOTION_TYPE(type) \
+       RETURN_VAL_IF(type >= SENSOR_MOTION_SNAP && type <= SENSOR_MOTION_NO_MOVE, SENSOR_ERROR_INVALID_PARAMETER)
+
+#define RETURN_IF_NOT_WAKEUP_TYPE(type) \
+       RETURN_VAL_IF(type > SENSOR_DEVICE_ORIENTATION, SENSOR_ERROR_NOT_SUPPORTED)
+
+#define RETURN_IF_ERROR(val) \
+       RETURN_VAL_IF(val < 0, val)
+
+#define MICROSECONDS(tv)        ((tv.tv_sec * 1000000ll) + tv.tv_usec)
+
+sensor_data_accuracy_e _accu_table[] = {
+       SENSOR_ACCURACY_UNDEFINED,
+       SENSOR_ACCURACY_BAD,
+       SENSOR_ACCURACY_NORMAL,
+       SENSOR_ACCURACY_GOOD,
+       SENSOR_ACCURACY_VERYGOOD,
+};
+
+sensor_type_t _TYPE[] = {
+       ACCELEROMETER_SENSOR,
+       ACCELEROMETER_SENSOR,
+       ACCELEROMETER_SENSOR,
+       ACCELEROMETER_SENSOR,
+       GEOMAGNETIC_SENSOR,
+       GEOMAGNETIC_SENSOR,
+       GYROSCOPE_SENSOR,
+       LIGHT_SENSOR,
+       PROXIMITY_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+};
+
+int _DTYPE[] = {
+       ACCELEROMETER_BASE_DATA_SET,
+       ACCELEROMETER_GRAVITY_DATA_SET,
+       ACCELEROMETER_LINEAR_ACCELERATION_DATA_SET,
+       ACCELEROMETER_ORIENTATION_DATA_SET,
+       GEOMAGNETIC_RAW_DATA_SET,
+       GEOMAGNETIC_BASE_DATA_SET,
+       GYRO_BASE_DATA_SET,
+       LIGHT_LUX_DATA_SET,
+       PROXIMITY_DISTANCE_DATA_SET,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+       MOTION_SENSOR,
+};
+
+int _EVENT[] = {
+       ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME,
+       ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME,
+       ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME,
+       ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME,
+       GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, 
+       GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME,
+       GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME,
+       LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, 
+       PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME,
+       MOTION_ENGINE_EVENT_SNAP,
+       MOTION_ENGINE_EVENT_SHAKE,
+       MOTION_ENGINE_EVENT_DOUBLETAP,
+       MOTION_ENGINE_EVENT_PANNING,
+       MOTION_ENGINE_EVENT_PANNING_BROWSE,
+       MOTION_ENGINE_EVENT_TILT,
+       MOTION_ENGINE_EVENT_TOP_TO_BOTTOM,
+       MOTION_ENGINE_EVENT_DIRECT_CALL,
+       MOTION_ENGINE_EVENT_SMART_ALERT,
+       MOTION_ENGINE_EVENT_NO_MOVE,
+};
+
+int _CALIBRATION[] = {
+       ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
+       ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
+       ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
+       ACCELEROMETER_EVENT_CALIBRATION_NEEDED,
+       GEOMAGNETIC_EVENT_CALIBRATION_NEEDED,
+       GEOMAGNETIC_EVENT_CALIBRATION_NEEDED,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+};
+
+
+int _WAKEUP[] = {
+       ACCELEROMETER_EVENT_SET_WAKEUP,
+       ACCELEROMETER_EVENT_SET_WAKEUP,
+       ACCELEROMETER_EVENT_SET_WAKEUP,
+       ACCELEROMETER_EVENT_SET_WAKEUP,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+       EMPTY_EVENT,
+};
+
+int _sensor_ids[] = {
+       ID_ACCELEOMETER,
+       ID_ACCELEOMETER,
+       ID_ACCELEOMETER,
+       ID_ACCELEOMETER,
+       ID_GEOMAGNETIC,
+       ID_GEOMAGNETIC,
+       ID_GYROSCOPE,
+       ID_LIGHT,
+       ID_PROXIMITY,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION,
+       ID_MOTION
+};
+
+
+
+#define _SID(id) (_sensor_ids[id])
+#define _ACCU(accuracy) (_accu_table[accuracy + 1])
+
+static int _sensor_connect(sensor_h handle, sensor_type_e type)
+{
+       int id = 0;
+       bool support = true;
+
+       RETURN_IF_NOT_TYPE(type);
+
+       if(handle->ids[_SID(type)] < 0){
+               sensor_is_supported(type, &support); 
+               if(!support)
+                       return SENSOR_ERROR_NOT_SUPPORTED;
+
+               id = sf_connect(_TYPE[type]);
+
+               DEBUG_PRINTF("%s sensor connect legacy=[%d] type=[%d]", TYPE_NAME(type), type, _TYPE[type]);
+               if(id < 0){
+                       return id == -2 ? SENSOR_ERROR_IO_ERROR : SENSOR_ERROR_OPERATION_FAILED;
+               }
+               DEBUG_PRINTF("%s sensor id created [%d]", TYPE_NAME(type), id);
+               handle->ids[_SID(type)] = id;
+       }
+       return SENSOR_ERROR_NONE;
+}
+
+static void _sensor_callback (unsigned int event_type, sensor_event_data_t* event, void* udata)
+{
+       int i = 0;
+       int data_num = 0;
+       sensor_data_t *data = NULL;
+       sensor_panning_data_t *panning_data = NULL;
+       int motion = 0;
+       int nid = 0;
+
+       struct timeval sv;
+       unsigned long long motion_time_stamp = 0;
+
+       sensor_h sensor = (sensor_h)udata;
+
+       switch(event_type)
+       {
+               case MOTION_ENGINE_EVENT_SNAP: 
+                       nid = SENSOR_MOTION_SNAP;
+                       break;
+               case MOTION_ENGINE_EVENT_SHAKE:
+                       nid = SENSOR_MOTION_SHAKE;
+                       break;
+               case MOTION_ENGINE_EVENT_DOUBLETAP:
+                       nid = SENSOR_MOTION_DOUBLETAP;
+                       break;
+               case MOTION_ENGINE_EVENT_PANNING:
+                       nid = SENSOR_MOTION_PANNING;
+                       break;
+               case MOTION_ENGINE_EVENT_TILT:
+                       nid = SENSOR_MOTION_TILT;
+                       break;
+                case MOTION_ENGINE_EVENT_PANNING_BROWSE:
+                        nid = SENSOR_MOTION_PANNING_BROWSE;
+                        break;
+               case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM:
+                       nid = SENSOR_MOTION_FACEDOWN;
+                       break;
+               case MOTION_ENGINE_EVENT_DIRECT_CALL:
+                       nid = SENSOR_MOTION_DIRECTCALL;
+                       break;
+                case MOTION_ENGINE_EVENT_SMART_ALERT:
+                        nid = SENSOR_MOTION_SMART_ALERT;
+                        break;
+                case MOTION_ENGINE_EVENT_NO_MOVE:
+                        nid = SENSOR_MOTION_NO_MOVE;
+                        break;
+               case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
+                       nid = SENSOR_ACCELEROMETER;
+                       break;
+                case ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME :
+                        nid = SENSOR_GRAVITY;
+                        break;
+                case ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME :
+                        nid = SENSOR_LINEAR_ACCELERATION;
+                        break;
+                case ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME :
+                        nid = SENSOR_DEVICE_ORIENTATION;
+                        break;
+               case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
+                       nid = SENSOR_MAGNETIC;
+                       break;
+               case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
+                       nid = SENSOR_ORIENTATION;
+                       break;
+               case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
+                       nid = SENSOR_GYROSCOPE;
+                       break;
+               case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
+                       nid = SENSOR_LIGHT;
+                       break;
+               case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
+                       nid = SENSOR_PROXIMITY;
+                       break;
+       }
+
+       if(sensor->cb_func[nid] == NULL || sensor->started[nid] == 0)
+               return;
+
+       switch(event_type)
+       {
+               case MOTION_ENGINE_EVENT_SNAP:
+               case MOTION_ENGINE_EVENT_SHAKE:
+                       motion = *(int*)event->event_data;
+                       break;
+               case MOTION_ENGINE_EVENT_PANNING:
+               case MOTION_ENGINE_EVENT_TILT:
+               case MOTION_ENGINE_EVENT_PANNING_BROWSE:
+                       panning_data = (sensor_panning_data_t *)event->event_data;
+                       break;
+               case MOTION_ENGINE_EVENT_DOUBLETAP:
+                       motion = *(int*)event->event_data;
+                       if(motion != MOTION_ENGIEN_DOUBLTAP_DETECTION)
+                               return;
+                       break;
+               case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM:
+                       motion = *(int*)event->event_data;
+                       if(motion != MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION)
+                               return;
+                       break;
+               case MOTION_ENGINE_EVENT_DIRECT_CALL:
+                       motion = *(int*)event->event_data;
+                       if(motion != MOTION_ENGINE_DIRECT_CALL_DETECTION)
+                               return;
+                       break;
+               case MOTION_ENGINE_EVENT_SMART_ALERT:
+                       motion = *(int*)event->event_data;
+                       if(motion != MOTION_ENGINE_SMART_ALERT_DETECTION)
+                               return;
+                       break;
+                case MOTION_ENGINE_EVENT_NO_MOVE:
+                        motion = *(int*)event->event_data;
+                        if(motion != MOTION_ENGINE_NO_MOVE_DETECTION)
+                                return;
+                        break;
+               case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
+               case ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME :
+               case ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME :
+               case ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME :
+               case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
+               case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
+               case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
+               case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
+               case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
+                       data = (sensor_data_t*)(event->event_data);
+                       data_num = (event->event_data_size)/sizeof(sensor_data_t);
+                       break;
+                       /*
+                          case PROXIMITY_EVENT_CHANGE_STATE :
+                          proximity = *(int*)(event->event_data) == PROXIMITY_STATE_FAR ? 0 : 1;
+                          break;
+                        */
+               default:
+                       DEBUG_PRINTF("unknown typed sensor happen!! event=%d\n", event_type);
+                       return;
+
+       }
+
+       switch(event_type)
+       {
+               case MOTION_ENGINE_EVENT_SNAP:
+                       gettimeofday(&sv, NULL);
+                       motion_time_stamp = MICROSECONDS(sv);
+                       ((sensor_motion_snap_event_cb)sensor->cb_func[nid])(motion_time_stamp, motion, sensor->cb_user_data[nid]);
+                       break;
+               case MOTION_ENGINE_EVENT_SHAKE:
+                       gettimeofday(&sv, NULL);
+                       motion_time_stamp = MICROSECONDS(sv);
+                       ((sensor_motion_shake_event_cb)sensor->cb_func[nid])(motion_time_stamp,motion, sensor->cb_user_data[nid]);
+                       break;
+               case MOTION_ENGINE_EVENT_DOUBLETAP:
+                       gettimeofday(&sv, NULL);
+                       motion_time_stamp = MICROSECONDS(sv);
+                       ((sensor_motion_doubletap_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
+                       break;
+               case MOTION_ENGINE_EVENT_TOP_TO_BOTTOM:
+                       gettimeofday(&sv, NULL);
+                       motion_time_stamp = MICROSECONDS(sv);
+                       ((sensor_motion_facedown_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
+                       break;
+               case MOTION_ENGINE_EVENT_PANNING:
+                       gettimeofday(&sv, NULL);
+                       motion_time_stamp = MICROSECONDS(sv);
+                       ((sensor_motion_panning_event_cb)sensor->cb_func[nid])(motion_time_stamp,panning_data->x, panning_data->y, sensor->cb_user_data[nid]);
+                       break;
+                case MOTION_ENGINE_EVENT_TILT:
+                        gettimeofday(&sv, NULL);
+                        motion_time_stamp = MICROSECONDS(sv);
+                        ((sensor_motion_tilt_event_cb)sensor->cb_func[nid])(motion_time_stamp,panning_data->x, panning_data->y, sensor->cb_user_data[nid]);
+                        break;
+                case MOTION_ENGINE_EVENT_PANNING_BROWSE:
+                        gettimeofday(&sv, NULL);
+                        motion_time_stamp = MICROSECONDS(sv);
+                        ((sensor_motion_panning_browse_event_cb)sensor->cb_func[nid])(motion_time_stamp,panning_data->x, panning_data->y, sensor->cb_user_data[nid]);
+                        break;
+               case MOTION_ENGINE_EVENT_DIRECT_CALL:
+                       gettimeofday(&sv, NULL);
+                       motion_time_stamp = MICROSECONDS(sv);
+                       ((sensor_motion_directcall_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
+                       break;
+                case MOTION_ENGINE_EVENT_SMART_ALERT:
+                        gettimeofday(&sv, NULL);
+                        motion_time_stamp = MICROSECONDS(sv);
+                        ((sensor_motion_smart_alert_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
+                        break;
+                case MOTION_ENGINE_EVENT_NO_MOVE:
+                        gettimeofday(&sv, NULL);
+                        motion_time_stamp = MICROSECONDS(sv);
+                        ((sensor_motion_no_move_event_cb)sensor->cb_func[nid])(motion_time_stamp,sensor->cb_user_data[nid]);
+                        break;
+               case ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
+                       for(i=0; i<data_num; i++){
+                               ((sensor_accelerometer_event_cb)sensor->cb_func[nid])
+                                       (data[i].time_stamp, _ACCU(data[i].data_accuracy), 
+                                        data[i].values[0],  data[i].values[1], data[i].values[2], 
+                                        sensor->cb_user_data[nid]);
+                       }
+                       break;
+                case ACCELEROMETER_EVENT_GRAVITY_DATA_REPORT_ON_TIME :
+                        for(i=0; i<data_num; i++){
+                                ((sensor_gravity_event_cb)sensor->cb_func[nid])
+                                        (data[i].time_stamp, _ACCU(data[i].data_accuracy),
+                                         data[i].values[0],  data[i].values[1], data[i].values[2],
+                                         sensor->cb_user_data[nid]);
+                        }
+                        break;
+                case ACCELEROMETER_EVENT_LINEAR_ACCELERATION_DATA_REPORT_ON_TIME :
+                        for(i=0; i<data_num; i++){
+                                ((sensor_linear_acceleration_event_cb)sensor->cb_func[nid])
+                                        (data[i].time_stamp, _ACCU(data[i].data_accuracy),
+                                         data[i].values[0],  data[i].values[1], data[i].values[2],
+                                         sensor->cb_user_data[nid]);
+                        }
+                        break;
+                case ACCELEROMETER_EVENT_ORIENTATION_DATA_REPORT_ON_TIME :
+                        for(i=0; i<data_num; i++){
+                                ((sensor_device_orientation_event_cb)sensor->cb_func[nid])
+                                        (data[i].time_stamp, _ACCU(data[i].data_accuracy),
+                                         data[i].values[0],  data[i].values[1], data[i].values[2],
+                                         sensor->cb_user_data[nid]);
+                        }
+                        break;
+               case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
+                       for(i=0; i<data_num; i++){
+                               ((sensor_magnetic_event_cb)sensor->cb_func[nid])
+                                       (data[i].time_stamp,_ACCU(data[i].data_accuracy), 
+                                        data[i].values[0],  data[i].values[1], data[i].values[2], 
+                                        sensor->cb_user_data[nid]);
+                       }
+                       break;
+               case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
+                       for(i=0; i<data_num; i++){
+                               ((sensor_orientation_event_cb)sensor->cb_func[nid])
+                                       (data[i].time_stamp,_ACCU(data[i].data_accuracy), 
+                                        data[i].values[0],  data[i].values[1], data[i].values[2], 
+                                        sensor->cb_user_data[nid]);
+                       }
+                       break;
+               case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
+                       for(i=0; i<data_num; i++){
+                               ((sensor_gyroscope_event_cb)sensor->cb_func[nid])
+                                       (data[i].time_stamp,_ACCU(data[i].data_accuracy), 
+                                        data[i].values[0],  data[i].values[1], data[i].values[2], 
+                                        sensor->cb_user_data[nid]);
+                       }
+                       break;
+               case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
+                       for(i=0; i<data_num; i++){
+                               ((sensor_light_event_cb)sensor->cb_func[nid])
+                                       (data[i].time_stamp, 
+                                        data[i].values[0], 
+                                        sensor->cb_user_data[nid]);
+                       }
+                       break;
+               case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
+                       for(i=0; i<data_num; i++){
+                               ((sensor_proximity_event_cb)sensor->cb_func[nid])
+                                       (data[i].time_stamp, 
+                                        data[i].values[0], 
+                                        sensor->cb_user_data[nid]);
+                       }
+                       break;
+       }
+}
+
+int sensor_is_supported(sensor_type_e type, bool* supported)
+{
+       DEBUG_PRINT("sensor_is_support");
+
+       RETURN_IF_NOT_TYPE(type);
+
+       if(supported == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *supported = !(sf_is_sensor_event_available(_TYPE[type], _EVENT[type]) < 0);
+       DEBUG_PRINTF("%s sensor available function return [%d]", TYPE_NAME(type), *supported);
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float* max, float* min, float* resolution)
+{
+       sensor_data_properties_t data_properties;
+       sensor_properties_t properties;
+
+       DEBUG_PRINT("sensor_get_spec");
+
+       RETURN_IF_MOTION_TYPE(type); 
+
+       RETURN_IF_NOT_TYPE(type);
+
+       if(sf_get_data_properties(_DTYPE[type], &data_properties) < 0)
+               RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
+
+       if(sf_get_properties(_TYPE[type], &properties) < 0)
+               RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
+
+       if(vendor != NULL)
+               *vendor = strdup(properties.sensor_vendor);
+       if(model != NULL)
+               *model = strdup(properties.sensor_name);
+       if(max != NULL)
+               *max = data_properties.sensor_max_range;
+       if(min != NULL)
+               *min = data_properties.sensor_min_range;
+       if(resolution != NULL)
+               *resolution = data_properties.sensor_resolution;
+
+       DEBUG_PRINTF("success get %s's format max=%f, min=%f, res=%f\n", TYPE_NAME(type), (max) ? *max : 0,(min) ? *min : 0, (resolution) ? *resolution : 0);
+
+       return SENSOR_ERROR_NONE;
+}
+
+
+int sensor_create(sensor_h* handle)
+{
+       struct sensor_handle_s* sensor = NULL;
+
+       DEBUG_PRINT("sensor_create");
+
+       if(handle == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       sensor = (struct sensor_handle_s*)malloc( sizeof(struct sensor_handle_s) );
+       if(sensor==NULL)
+               RETURN_ERROR(SENSOR_ERROR_OUT_OF_MEMORY);
+       else
+       {
+               SENSOR_INIT(sensor);
+
+               *handle = (sensor_h)sensor;
+
+               return SENSOR_ERROR_NONE;
+       }
+}
+
+int sensor_destroy(sensor_h handle)
+{
+
+       int i=0;
+       RETURN_IF_NOT_HANDLE(handle);
+
+       DEBUG_PRINT("sensor_destroy");
+
+       for(i=0; i<ID_NUMBERS; i++){
+               if( handle->ids[i] >= 0 ){
+                       if(sf_disconnect(handle->ids[i]) >= 0){
+                               handle->ids[i] = -1;
+                       }
+               }
+       }
+
+       free(handle);
+       handle = NULL;
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_start(sensor_h handle, sensor_type_e type)
+{
+       int err;
+       DEBUG_PRINT("sensor_start");
+       RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_NOT_TYPE(type);
+
+       if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
+               return err;
+       }
+
+       if (sf_start(handle->ids[_SID(type)], handle->sensor_option[type]) < 0) {
+               RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+       } else {
+               handle->started[type] = 1;
+               return SENSOR_ERROR_NONE;
+       }
+}
+
+int sensor_stop(sensor_h handle, sensor_type_e type)
+{
+       DEBUG_PRINT("sensor_stop");
+       RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_NOT_TYPE(type);
+       if (sf_stop(handle->ids[_SID(type)]) < 0) {
+               RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+       } else {
+               handle->started[type] = 0;
+               return SENSOR_ERROR_NONE;
+       }
+}
+
+static void _sensor_calibration (unsigned int event_type, sensor_event_data_t* event, void* udata)
+{
+       sensor_h sensor = (sensor_h)udata;
+
+       switch (event_type) {
+               case ACCELEROMETER_EVENT_CALIBRATION_NEEDED:
+                       if(sensor->calib_func[SENSOR_ACCELEROMETER] != NULL){
+                               ((sensor_calibration_cb)sensor->calib_func[SENSOR_ACCELEROMETER])(sensor->calib_user_data[SENSOR_ACCELEROMETER]);
+                       }
+                       break;
+               case GEOMAGNETIC_EVENT_CALIBRATION_NEEDED:
+                       if(sensor->calib_func[SENSOR_MAGNETIC] != NULL){
+                               ((sensor_calibration_cb)sensor->calib_func[SENSOR_MAGNETIC])(sensor->calib_user_data[SENSOR_MAGNETIC]);
+                       }
+                       if(sensor->calib_func[SENSOR_ORIENTATION] != NULL){
+                               ((sensor_calibration_cb)sensor->calib_func[SENSOR_ORIENTATION])(sensor->calib_user_data[SENSOR_ORIENTATION]);
+                       }
+                       break;
+               default:
+                       DEBUG_PRINTF("not calibration event happened in calibration callback!! event=%d", event_type);
+                       return;
+       }
+}
+
+static int _sensor_set_calibration_cb(sensor_h handle, sensor_type_e type, sensor_calibration_cb callback, void *user_data)
+{
+       int ret, err;
+
+       DEBUG_PRINTF("%s sensor register calibration callback", TYPE_NAME(type));
+
+       RETURN_IF_NOT_HANDLE(handle);
+       switch(type){
+               case SENSOR_ACCELEROMETER:
+               case SENSOR_GRAVITY:
+               case SENSOR_LINEAR_ACCELERATION:
+               case SENSOR_DEVICE_ORIENTATION:
+               case SENSOR_MAGNETIC:
+               case SENSOR_ORIENTATION:
+                       break;
+               default:
+                       RETURN_ERROR(SENSOR_ERROR_NOT_NEED_CALIBRATION);
+       }
+
+       ret = sf_is_sensor_event_available( _TYPE[type], _CALIBRATION[type] );
+       if (ret != 0 ){
+               DEBUG_PRINTF("Unsupported calibration ret=[%d] error=[%d] legacy=[%d] type=[%d] cal_id=[%d]", ret, SENSOR_ERROR_NOT_NEED_CALIBRATION, type, _TYPE[type], _CALIBRATION[type]);
+               RETURN_ERROR(SENSOR_ERROR_NOT_NEED_CALIBRATION);
+       }
+
+       if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
+               return err;
+       }
+
+       handle->calib_func[type] = callback;
+       handle->calib_user_data[type] = user_data;
+
+       DEBUG_PRINTF("type : %s / id : %d / event : %x ", TYPE_NAME(type), handle->ids[_SID(type)], _CALIBRATION[type]);
+
+       ret = sf_register_event(handle->ids[_SID(type)], _CALIBRATION[type], NULL, _sensor_calibration, handle);
+       if(ret < 0){
+               handle->calib_func[type] = NULL;
+               handle->calib_user_data[type] = NULL;
+               if(ret == -2)
+                       RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+               else
+                       RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+       }
+
+       return SENSOR_ERROR_NONE;
+}
+
+static int _sensor_unset_calibration_cb(sensor_h handle, sensor_type_e type)
+{
+       int ret;
+
+       DEBUG_PRINTF("%s sensor register calibration callback", TYPE_NAME(type));
+
+       RETURN_IF_NOT_HANDLE(handle);
+       switch (type) {
+               case SENSOR_ACCELEROMETER:
+               case SENSOR_GRAVITY:
+                case SENSOR_LINEAR_ACCELERATION:
+                case SENSOR_DEVICE_ORIENTATION:
+               case SENSOR_MAGNETIC:
+               case SENSOR_ORIENTATION:
+                       break;
+               default:
+                       RETURN_ERROR(SENSOR_ERROR_NOT_NEED_CALIBRATION);
+       }
+
+       if(handle->calib_func[type] == NULL)
+               return SENSOR_ERROR_NONE;
+
+       ret = sf_unregister_event(handle->ids[_SID(type)], _CALIBRATION[type]);
+
+       if (ret < 0){
+               if(ret == -2)
+                       RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+               else
+                       RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+       }
+
+       handle->calib_func[type] = NULL;
+       handle->calib_user_data[type] = NULL;
+
+       return SENSOR_ERROR_NONE;
+}
+
+static void _sensor_wakeup (unsigned int event_type, sensor_event_data_t* event, void* udata)
+{
+        sensor_h sensor = (sensor_h)udata;
+
+        switch (event_type) {
+                case ACCELEROMETER_EVENT_SET_WAKEUP:
+                        if(sensor->wakeup_func[SENSOR_ACCELEROMETER] != NULL){
+                                ((sensor_awake_cb)sensor->wakeup_func[SENSOR_ACCELEROMETER])(sensor->wakeup_user_data[SENSOR_ACCELEROMETER]);
+                        }
+                        break;
+                default:
+                        DEBUG_PRINTF("not wakeup event happened in wakeup callback!! event=%d", event_type);
+                        return;
+        }
+}
+
+static int _sensor_set_wakeup_cb(sensor_h handle, sensor_type_e type, sensor_awake_cb callback, void *user_data)
+{
+        int ret, err;
+
+        DEBUG_PRINTF("%s sensor register wakeup callback", TYPE_NAME(type));
+
+        RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_NOT_WAKEUP_TYPE(type);
+
+        ret = sf_is_sensor_event_available( _TYPE[type], _WAKEUP[type] );
+        if (ret != 0 ){
+                DEBUG_PRINTF("Unsupported wakeup ret=[%d] error=[%d] legacy=[%d] type=[%d] wakeup_id=[%d]", ret, SENSOR_ERROR_NOT_SUPPORTED, type, _TYPE[type], _WAKEUP[type]);
+                RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
+        }
+
+        if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
+                return err;
+        }
+
+        handle->wakeup_func[type] = callback;
+        handle->wakeup_user_data[type] = user_data;
+
+        DEBUG_PRINTF("type : %s / id : %d / event : %x ", TYPE_NAME(type), handle->ids[_SID(type)], _WAKEUP[type]);
+
+        ret = sf_register_event(handle->ids[_SID(type)], _WAKEUP[type], NULL, _sensor_wakeup, handle);
+        if(ret < 0){
+                handle->wakeup_func[type] = NULL;
+                handle->wakeup_user_data[type] = NULL;
+                if(ret == -2)
+                        RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+                else
+                        RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+        }
+
+        return SENSOR_ERROR_NONE;
+}
+
+
+static int _sensor_unset_wakeup_cb(sensor_h handle, sensor_type_e type)
+{
+        int ret;
+
+        DEBUG_PRINTF("%s sensor unregister wakeup callback", TYPE_NAME(type));
+
+        RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_NOT_WAKEUP_TYPE(type);
+
+        if(handle->wakeup_func[type] == NULL)
+                return SENSOR_ERROR_NONE;
+
+        ret = sf_unregister_event(handle->ids[_SID(type)], _WAKEUP[type]);
+
+        if (ret < 0){
+                if(ret == -2)
+                        RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+                else
+                        RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+        }
+
+        handle->wakeup_func[type] = NULL;
+        handle->wakeup_user_data[type] = NULL;
+
+        return SENSOR_ERROR_NONE;
+}
+
+
+static int _sensor_change_data_cb (sensor_h handle, sensor_type_e type, int rate)
+{
+        int err = 0;
+        event_condition_t condition;
+
+        RETURN_IF_NOT_HANDLE(handle);
+        RETURN_IF_NOT_TYPE(type);
+
+        DEBUG_PRINTF("sensor change condition %s", TYPE_NAME(type));
+
+        if(rate < 0){
+                RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+        }
+
+        if(rate > 0){
+                condition.cond_op = CONDITION_EQUAL;
+                condition.cond_value1 = rate;
+        }
+
+        err = sf_change_event_condition(handle->ids[_SID(type)], _EVENT[type], (rate > 0 ? &condition : NULL));
+
+        DEBUG_PRINTF("%s sensor change condition function return [%d] event=[%d]", TYPE_NAME(type), err, _EVENT[type]);
+
+        if(err < 0){
+                if(err == -2)
+                        RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+                else
+                        RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+        }
+
+        return SENSOR_ERROR_NONE;
+}
+
+static int _sensor_set_data_cb (sensor_h handle, sensor_type_e type, int rate, void* cb, void* user_data)
+{
+       int err = 0;
+       event_condition_t condition;
+
+       RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_NOT_TYPE(type);
+
+       DEBUG_PRINTF("sensor register callback %s", TYPE_NAME(type));
+
+       if(rate < 0){
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+       }
+
+       if(rate > 0){
+               condition.cond_op = CONDITION_EQUAL;
+               condition.cond_value1 = rate;
+       }
+
+       handle->cb_func[type] = cb; 
+       handle->cb_user_data[type] = user_data;
+
+       if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE){
+               DEBUG_PRINTF("%s sensor connect error handle=[%d] legacy=[%d] err=[%d]", TYPE_NAME(type), handle, type, err);
+               return err;
+       }
+
+       err = sf_register_event(handle->ids[_SID(type)], _EVENT[type],
+                       (rate > 0 ? &condition : NULL), _sensor_callback, handle);
+
+       DEBUG_PRINTF("%s sensor register function return [%d] event=[%x]", TYPE_NAME(type), err, _EVENT[type]);
+
+       if(err < 0){
+               handle->cb_func[type] = NULL;
+               handle->cb_user_data[type] = NULL;
+               if(err == -2)
+                       RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+               else
+                       RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+       }
+
+       return SENSOR_ERROR_NONE;
+}
+
+static int _sensor_unset_data_cb (sensor_h handle, sensor_type_e type)
+{
+       int error;
+       DEBUG_PRINTF("sensor unregister callback %s", TYPE_NAME(type));
+       RETURN_IF_NOT_HANDLE(handle);
+       if (handle->ids[_SID(type)] < 0 )
+               return SENSOR_ERROR_INVALID_PARAMETER;
+
+       error = sf_unregister_event(handle->ids[_SID(type)], _EVENT[type]);
+
+       if (error < 0){
+               if(error == -2)
+                       RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+               else
+                       RETURN_ERROR(SENSOR_ERROR_OPERATION_FAILED);
+       }
+
+       handle->cb_func[type] = NULL;
+       handle->cb_user_data[type] = NULL;
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_accelerometer_set_cb(sensor_h handle, int rate, sensor_accelerometer_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_ACCELEROMETER, rate, (void*) callback, user_data);
+}
+
+int sensor_accelerometer_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_ACCELEROMETER);
+}
+
+int sensor_gravity_set_cb(sensor_h handle, int rate, sensor_gravity_event_cb callback, void* user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_GRAVITY, rate, (void*) callback, user_data);
+}
+
+int sensor_gravity_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_GRAVITY);
+}
+
+int sensor_linear_acceleration_set_cb(sensor_h handle, int rate, sensor_linear_acceleration_event_cb callback, void* user_data)
+{
+        return _sensor_set_data_cb(handle, SENSOR_LINEAR_ACCELERATION, rate, (void*) callback, user_data);
+}
+
+int sensor_linear_acceleration_unset_cb(sensor_h handle)
+{
+        return _sensor_unset_data_cb(handle, SENSOR_LINEAR_ACCELERATION);
+}
+
+int sensor_device_orientation_set_cb(sensor_h handle, int rate, sensor_device_orientation_event_cb callback, void* user_data)
+{
+        return _sensor_set_data_cb(handle, SENSOR_DEVICE_ORIENTATION, rate, (void*) callback, user_data);
+}
+
+int sensor_device_orientation_unset_cb(sensor_h handle)
+{
+        return _sensor_unset_data_cb(handle, SENSOR_DEVICE_ORIENTATION);
+}
+
+int sensor_magnetic_set_cb(sensor_h handle, int rate, sensor_magnetic_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MAGNETIC, rate, (void*) callback, user_data);
+}
+
+int sensor_magnetic_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MAGNETIC);
+}
+
+int sensor_magnetic_set_calibration_cb(sensor_h handle, sensor_calibration_cb callback, void *user_data)
+{
+       return _sensor_set_calibration_cb(handle, SENSOR_MAGNETIC, callback, user_data);
+}
+int sensor_magnetic_unset_calibration_cb(sensor_h handle)
+{
+       return _sensor_unset_calibration_cb(handle, SENSOR_MAGNETIC);
+}
+
+int sensor_orientation_set_cb(sensor_h handle, int rate, sensor_orientation_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_ORIENTATION, rate, (void*) callback, user_data);
+}
+
+int sensor_orientation_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_ORIENTATION);
+}
+int sensor_orientation_set_calibration_cb(sensor_h handle, sensor_calibration_cb callback, void *user_data)
+{
+       return _sensor_set_calibration_cb(handle, SENSOR_ORIENTATION, callback, user_data);
+}
+int sensor_orientation_unset_calibration_cb(sensor_h handle)
+{
+       return _sensor_unset_calibration_cb(handle, SENSOR_ORIENTATION);
+}
+
+int sensor_gyroscope_set_cb(sensor_h handle, int rate, sensor_gyroscope_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_GYROSCOPE, rate, (void*) callback, user_data);
+}
+
+int sensor_gyroscope_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_GYROSCOPE);
+}
+
+int sensor_light_set_cb(sensor_h handle, int rate, sensor_light_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_LIGHT, rate, (void*) callback, user_data);
+}
+
+int sensor_light_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_LIGHT);
+}
+
+int sensor_proximity_set_cb(sensor_h handle, int interval_ms, sensor_proximity_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_PROXIMITY, interval_ms, (void*) callback, user_data);
+}
+
+int sensor_proximity_unset_cb(sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_PROXIMITY);
+}
+
+static int _sensor_read_data(sensor_h handle, sensor_type_e type, 
+               sensor_data_accuracy_e* accuracy, float* values, int values_size)
+{
+       int err = 0;
+       sensor_data_t data;
+
+       RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_MOTION_TYPE(type);
+       RETURN_IF_NOT_TYPE(type);
+
+       DEBUG_PRINTF("sensor read data %s", TYPE_NAME(type));
+
+       if( (err = _sensor_connect(handle, type)) != SENSOR_ERROR_NONE)
+               return err;
+       if ( sf_get_data(handle->ids[_SID(type)], _DTYPE[type], &data) < 0 )
+       {
+               RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+       }
+
+       // this error will never happen. but it exist for more safe code.. 
+       if(values_size > 12 || values_size < 0)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       if(accuracy != NULL)
+               *accuracy = _ACCU(data.data_accuracy);
+       memcpy(values, data.values, values_size * sizeof(float));
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_accelerometer_read_data (sensor_h handle, 
+               sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
+{
+       float values[3] = {0,0,0};
+       int err = _sensor_read_data(handle, SENSOR_ACCELEROMETER, accuracy, values, 3);
+       if(err < 0) return err;
+
+       if(x == NULL || y == NULL || z == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *x = values[0];
+       *y = values[1];
+       *z = values[2];
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_gravity_read_data (sensor_h handle, 
+               sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
+{
+        float values[3] = {0,0,0};
+        int err = _sensor_read_data(handle, SENSOR_GRAVITY, accuracy, values, 3);
+        if(err < 0) return err;
+
+        if(x == NULL || y == NULL || z == NULL)
+                RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+        *x = values[0];
+        *y = values[1];
+        *z = values[2];
+
+        return SENSOR_ERROR_NONE;
+}
+
+int sensor_linear_acceleration_read_data (sensor_h handle,
+                sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
+{
+        float values[3] = {0,0,0};
+        int err = _sensor_read_data(handle, SENSOR_LINEAR_ACCELERATION, accuracy, values, 3);
+        if(err < 0) return err;
+
+        if(x == NULL || y == NULL || z == NULL)
+                RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+        *x = values[0];
+        *y = values[1];
+        *z = values[2];
+
+        return SENSOR_ERROR_NONE;
+}
+
+int sensor_device_orientation_read_data (sensor_h handle,
+                sensor_data_accuracy_e* accuracy, float* yaw, float* pitch, float* roll)
+{
+        float values[3] = {0,0,0};
+        int err = _sensor_read_data(handle, SENSOR_DEVICE_ORIENTATION, accuracy, values, 3);
+        if(err < 0) return err;
+
+        if(yaw == NULL || pitch == NULL || roll == NULL)
+                RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+        *yaw = values[0];
+        *pitch = values[1];
+        *roll = values[2];
+
+        return SENSOR_ERROR_NONE;
+}
+
+int sensor_magnetic_read_data      (sensor_h handle, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
+{
+       float values[3] = {0,0,0};
+       int err = _sensor_read_data(handle, SENSOR_MAGNETIC, accuracy, values, 3);
+       if(err < 0) return err;
+
+       if(x == NULL || y == NULL || z == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *x = values[0];
+       *y = values[1];
+       *z = values[2];
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_orientation_read_data   (sensor_h handle, sensor_data_accuracy_e* accuracy, float* azimuth, float* pitch, float* roll)
+{
+       float values[3] = {0,0,0};
+       int err = _sensor_read_data(handle, SENSOR_ORIENTATION, accuracy, values, 3);
+       if(err < 0) return err;
+
+       if(azimuth == NULL || pitch == NULL || roll == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *azimuth = values[0];
+       *pitch = values[1];
+       *roll = values[2];
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_gyroscope_read_data     (sensor_h handle, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z)
+{
+       float values[3] = {0,0,0};
+       int err = _sensor_read_data(handle, SENSOR_GYROSCOPE, accuracy, values, 3);
+       if(err < 0) return err;
+
+       if(x == NULL || y == NULL || z == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *x = values[0];
+       *y = values[1];
+       *z = values[2];
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_light_read_data         (sensor_h handle, float* lux)
+{
+       float values[1] = {0};
+       int err = _sensor_read_data(handle, SENSOR_LIGHT, NULL, values, 1);
+       if(err < 0) return err;
+
+       if(lux == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *lux = values[0];
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_proximity_read_data     (sensor_h handle, float* distance)
+{
+       float values[1] = {0};
+       int err = _sensor_read_data(handle, SENSOR_PROXIMITY, NULL, values, 1);
+       if(err < 0) return err;
+
+       if(distance == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *distance = values[0];
+
+       return SENSOR_ERROR_NONE;
+}
+
+
+int sensor_motion_snap_set_cb    (sensor_h handle, sensor_motion_snap_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MOTION_SNAP, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_snap_unset_cb                (sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MOTION_SNAP);
+}
+
+int sensor_motion_shake_set_cb   (sensor_h handle, sensor_motion_shake_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MOTION_SHAKE, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_shake_unset_cb (sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MOTION_SHAKE);
+}
+
+int sensor_motion_doubletap_set_cb    (sensor_h handle, sensor_motion_doubletap_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MOTION_DOUBLETAP, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_doubletap_unset_cb (sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MOTION_DOUBLETAP);
+}
+
+int sensor_motion_panning_set_cb    (sensor_h handle, sensor_motion_panning_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MOTION_PANNING, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_panning_unset_cb (sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MOTION_PANNING);
+}
+
+int sensor_motion_tilt_set_cb    (sensor_h handle, sensor_motion_tilt_event_cb callback, void *user_data)
+{
+        return _sensor_set_data_cb(handle, SENSOR_MOTION_TILT, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_tilt_unset_cb (sensor_h handle)
+{
+        return _sensor_unset_data_cb(handle, SENSOR_MOTION_TILT);
+}
+int sensor_motion_panning_browse_set_cb    (sensor_h handle, sensor_motion_panning_browse_event_cb callback, void *user_data)
+{
+        return _sensor_set_data_cb(handle, SENSOR_MOTION_PANNING_BROWSE, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_panning_browse_unset_cb (sensor_h handle)
+{
+        return _sensor_unset_data_cb(handle, SENSOR_MOTION_PANNING_BROWSE);
+}
+
+int sensor_motion_facedown_set_cb    (sensor_h handle, sensor_motion_facedown_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MOTION_FACEDOWN, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_facedown_unset_cb (sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MOTION_FACEDOWN);
+}
+
+int sensor_motion_directcall_set_cb    (sensor_h handle, sensor_motion_directcall_event_cb callback, void *user_data)
+{
+       return _sensor_set_data_cb(handle, SENSOR_MOTION_DIRECTCALL, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_directcall_unset_cb (sensor_h handle)
+{
+       return _sensor_unset_data_cb(handle, SENSOR_MOTION_DIRECTCALL);
+}
+
+int sensor_motion_smart_alert_set_cb    (sensor_h handle, sensor_motion_smart_alert_event_cb callback, void *user_data)
+{
+        return _sensor_set_data_cb(handle, SENSOR_MOTION_SMART_ALERT, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_smart_alert_unset_cb (sensor_h handle)
+{
+        return _sensor_unset_data_cb(handle, SENSOR_MOTION_SMART_ALERT);
+}
+
+int sensor_motion_no_move_set_cb    (sensor_h handle, sensor_motion_no_move_event_cb callback, void *user_data)
+{
+        return _sensor_set_data_cb(handle, SENSOR_MOTION_NO_MOVE, 0, (void*) callback, user_data);
+}
+
+int sensor_motion_no_move_unset_cb (sensor_h handle)
+{
+        return _sensor_unset_data_cb(handle, SENSOR_MOTION_NO_MOVE);
+}
+
+int sensor_awake_unset_cb(sensor_h handle, sensor_type_e type)
+{
+       return _sensor_unset_wakeup_cb(handle, type);
+}
+
+int sensor_awake_set_cb(sensor_h handle, sensor_type_e type, sensor_awake_cb callback, void* user_data)
+{
+       return _sensor_set_wakeup_cb(handle, type, callback, user_data);
+}
+
+int sensor_awake_is_enabled(sensor_h handle, sensor_type_e type, bool *enable)
+{
+       RETURN_IF_NOT_TYPE(type);
+       RETURN_IF_NOT_WAKEUP_TYPE(type);
+       *enable = (handle->wakeup_func[type] != NULL) ? true : false;
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_awake_is_supported(sensor_type_e type, bool *supported)
+{
+       DEBUG_PRINT("sensor_is_support");
+
+       RETURN_IF_NOT_TYPE(type);
+       RETURN_IF_NOT_WAKEUP_TYPE(type);
+
+       if(supported == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *supported = !(sf_is_sensor_event_available(_TYPE[type], _WAKEUP[type]) < 0);
+       DEBUG_PRINTF("%s sensor available function return [%d]", TYPE_NAME(type), *supported);
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_get_delay_boundary(sensor_type_e type, int *min, int *max)
+{
+       RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
+}
+
+int sensor_util_get_declination(float latitude, float longitude, float altitude, float *declination)
+{
+       if(declination == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       setCoordinate(latitude, longitude, altitude, declination, NULL, 1);
+       
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_angle_change(float R[], float prevR[], float angleChange[])
+{
+       if(-1 == getAngleChange(R, prevR, angleChange))
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_orientation(float R[], float values[])
+{
+       if(R == NULL || values == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       values[0] = (float)atan2(R[1], R[4]);
+       values[1] = (float)asin(-R[7]);
+       values[2] = (float)atan2(-R[6], R[8]);
+
+       return SENSOR_ERROR_NONE;       
+       
+}
+
+int sensor_util_get_inclination(float I[], float* inclination)
+{
+       if(I == NULL || inclination == NULL)
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       *inclination = atan2(I[5], I[4]);
+
+       RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
+}
+
+int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[])
+{
+       if(-1 == remapCoordinateSystem(inR, x, y, outR))
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_rotation_matrix_from_vector(float Vx, float Vy, float Vz, float R[])
+{
+       float RV[4] = {0, Vx, Vy, Vz};
+
+       RV[0] = 1 - Vx * Vx - Vy*Vy - Vz*Vz;
+       RV[0] = (Vx > 0) ? (float)(sqrt(Vx)) : 0;
+
+       if( -1 == quatToMatrix(RV, R))
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       return SENSOR_ERROR_NONE;
+}
+
+int sensor_util_get_rotation_matrix(float Gx, float Gy, float Gz,float Mx, float My, float Mz,float R[], float I[])
+{
+       float G[3] = {Gx, Gy, Gz};
+       float M[3] = {Mx, My, Mz};
+
+       if(-1 == getRotationMatrix(G, M, R, I))
+               RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
+
+       return SENSOR_ERROR_NONE;
+}
+
+
+int sensor_accelerometer_set_interval(sensor_h sensor, int interval_ms)
+{
+       return _sensor_change_data_cb(sensor, SENSOR_ACCELEROMETER, interval_ms);
+}
+
+int sensor_gravity_set_interval(sensor_h sensor, int interval_ms)
+{
+        return _sensor_change_data_cb(sensor, SENSOR_ACCELEROMETER, interval_ms);
+}
+
+int sensor_linear_acceleration_set_interval(sensor_h sensor, int interval_ms)
+{
+        return _sensor_change_data_cb(sensor, SENSOR_LINEAR_ACCELERATION, interval_ms);
+}
+
+int sensor_device_orientation_set_interval(sensor_h sensor, int interval_ms)
+{
+        return _sensor_change_data_cb(sensor, SENSOR_DEVICE_ORIENTATION, interval_ms);
+}
+
+int sensor_gyroscope_set_interval(sensor_h sensor, int interval_ms)
+{
+       return _sensor_change_data_cb(sensor, SENSOR_GYROSCOPE, interval_ms);
+}
+
+int sensor_light_set_interval(sensor_h sensor, int interval_ms)
+{
+       return _sensor_change_data_cb(sensor, SENSOR_LIGHT, interval_ms);
+}
+
+int sensor_magnetic_set_interval(sensor_h sensor, int interval_ms)
+{
+       return _sensor_change_data_cb(sensor, SENSOR_MAGNETIC, interval_ms);
+}
+
+int sensor_orientation_set_interval(sensor_h sensor, int interval_ms)
+{
+       return _sensor_change_data_cb(sensor, SENSOR_ORIENTATION, interval_ms);
+}
+
+int sensor_proximity_set_interval(sensor_h sensor, int interval_ms)
+{
+       return _sensor_change_data_cb(sensor, SENSOR_PROXIMITY, interval_ms);
+}
+
+int sensor_set_always_on(sensor_h handle, sensor_type_e type)
+{
+       RETURN_IF_NOT_HANDLE(handle);
+       RETURN_IF_MOTION_TYPE(type);
+       RETURN_IF_NOT_TYPE(type);
+
+       if(-1 == sf_change_sensor_option(handle->ids[_SID(type)], 1))
+               RETURN_ERROR(SENSOR_ERROR_IO_ERROR);
+
+       return SENSOR_ERROR_NONE;
+}