2.0 beta code 2.0alpha master 2.0_alpha accepted/tizen/20130520.161324 submit/master/20120920.151031 submit/tizen/20130520.164515
authorPius Lee <pius.lee@samsung.com>
Wed, 22 Aug 2012 12:52:58 +0000 (21:52 +0900)
committerPius Lee <pius.lee@samsung.com>
Wed, 22 Aug 2012 12:52:58 +0000 (21:52 +0900)
19 files changed:
debian/README [deleted file]
debian/capi-system-sensor-dev.install [deleted file]
debian/capi-system-sensor-dev.postinst [deleted file]
debian/capi-system-sensor.install [deleted file]
debian/capi-system-sensor.postinst [deleted file]
debian/changelog [deleted file]
debian/compat [deleted file]
debian/control [deleted file]
debian/rules [deleted file]
include/sensor_private.h [changed mode: 0755->0644]
include/sensors.h
packaging/capi-system-sensor.spec
src/sensor.c
test/CMakeLists.txt [new file with mode: 0755]
test/accelerometer-gravity-with-linear-acceleration.c [new file with mode: 0644]
test/gyroscope-calc-anger.c [new file with mode: 0644]
test/rotation.c [new file with mode: 0644]
test/supported-sensor.c [new file with mode: 0644]
test/system-sensor.c [new file with mode: 0644]

diff --git a/debian/README b/debian/README
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/debian/capi-system-sensor-dev.install b/debian/capi-system-sensor-dev.install
deleted file mode 100644 (file)
index 761a28b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/usr/include/*
-/usr/include/*/*
-/usr/lib/pkgconfig/*.pc
-
diff --git a/debian/capi-system-sensor-dev.postinst b/debian/capi-system-sensor-dev.postinst
deleted file mode 100644 (file)
index 1a24852..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#!/bin/sh
diff --git a/debian/capi-system-sensor.install b/debian/capi-system-sensor.install
deleted file mode 100644 (file)
index 4a755a4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/lib*.so*
diff --git a/debian/capi-system-sensor.postinst b/debian/capi-system-sensor.postinst
deleted file mode 100644 (file)
index 1a24852..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#!/bin/sh
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644 (file)
index 05f6f5d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-capi-system-sensor (0.1.0-9) unstable; urgency=low
-
-  * now, version will be attached to shared object extension.
-  * Git: api/sensor
-  * Tag: capi-system-sensor_0.1.0-9
-
- -- pius lee <pius.lee@samsung.com>  Thu, 16 Feb 2012 17:25:49 +0900
-
-capi-system-sensor (0.1.0-8) unstable; urgency=low
-
-  * fix sensor_get_spec for light and proximity (lux, centimeter)
-  * Git: api/sensor
-  * Tag: capi-system-sensor_0.1.0-8
-
- -- pius lee <pius.lee@samsung.com>  Thu, 09 Feb 2012 16:01:52 +0900
-
-capi-system-sensor (0.1.0-7) unstable; urgency=low
-
-  * light and proximity sensor modified. sensor will be measured lux and centimeter.
-  * Git: api/sensor
-  * Tag: capi-system-sensor_0.1.0-7
-
- -- pius lee <pius.lee@samsung.com>  Thu, 02 Feb 2012 18:50:31 +0900
-
-capi-system-sensor (0.1.0-6) unstable; urgency=low
-
-  * fix bug for calibration callback's invalidate user data
-  * Git: api/sensor
-  * Tag: capi-system-sensor_0.1.0-6
-
- -- Pius Lee <pius.lee@samsung.com>  Tue, 27 Dec 2011 16:11:32 +0900
-
-capi-system-sensor (0.1.0-5) unstable; urgency=low
-
-  * fix bugs in the every read functions
-  * Git: api/sensor
-  * Tag: capi-system-sensor_0.1.0-5
-
- -- Pius Lee <pius.lee@samsung.com>  Wed, 21 Dec 2011 20:45:19 +0900
-
-capi-system-sensor (0.1.0-4) unstable; urgency=low
-
-  * update version
-  * Git: api/sensor
-  * Tag: capi-system-sensor_0.1.0-4
-
- -- Pius Lee <pius.lee@samsung.com>  Thu, 15 Dec 2011 13:53:27 +0900
-
-capi-system-sensor (0.0.1-1) unstable; urgency=low
-
-  * Initial release.
-
- -- Pius Lee <pius.lee@samsung.com>  Wed, 07 Dec 2011 12:53:15 +0900
diff --git a/debian/compat b/debian/compat
deleted file mode 100644 (file)
index 7ed6ff8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644 (file)
index 979cd71..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Source: capi-system-sensor
-Section: libs
-Priority: extra
-Maintainer: pius lee <pius.lee@samsung.com>
-Build-Depends: debhelper (>= 5), dlog-dev, libslp-sensor-dev, capi-base-common-dev, libglib2.0-dev
-
-Package: capi-system-sensor
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: A Sensor library in Tizen Native API
-
-Package: capi-system-sensor-dev
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-system-sensor (= ${Source-Version}), dlog-dev, libslp-sensor-dev, capi-base-common-dev
-Description: A Sensor library in Tizen Native API (DEV)
-
-Package: capi-system-sensor-dbg
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-system-sensor (= ${Source-Version})
-Description: A Sensor library in Tizen Native API (DBG)
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index c3c71aa..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/make -f
-
-FULLVER ?= $(shell dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2 | cut -d '-' -f 1)
-MAJORVER ?= $(shell echo $(FULLVER) | cut -d '.' -f 1)
-
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
-       CFLAGS += -O0
-else
-       CFLAGS += -O2
-endif
-CMAKE_ROOT_DIR ?= $(CURDIR)
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-configure: configure-stamp
-configure-stamp:
-       dh_testdir
-       mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER}
-       touch configure-stamp
-
-
-build: build-stamp
-build-stamp: configure-stamp 
-       dh_testdir
-       cd $(CMAKE_BUILD_DIR) && $(MAKE)
-       touch $@
-
-clean:
-       cd $(CMAKE_ROOT_DIR)
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp configure-stamp
-       rm -f `find . -name *.pc`
-       rm -rf $(CMAKE_BUILD_DIR)
-       dh_clean
-       
-install: build
-       dh_testdir
-       dh_testroot
-       dh_clean -k 
-       dh_installdirs
-
-       cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-binary-indep: build install
-
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-       dh_installchangelogs 
-       dh_installdocs
-       dh_installexamples
-       dh_install --sourcedir=debian/tmp
-       dh_installman
-       dh_link
-       dh_strip --dbg-package=capi-system-sensor-dbg
-       dh_fixperms
-       dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
-
old mode 100755 (executable)
new mode 100644 (file)
index 5f7af1d..05707a5 100755 (executable)
@@ -20,8 +20,7 @@
 #ifndef __SENSOR_H__
 #define __SENSOR_H__
 
-#include <tizen_error.h>
-#include <tizen_type.h>
+#include <tizen.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -102,6 +101,12 @@ 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;
 /**
  * @}
@@ -165,6 +170,7 @@ typedef void (*sensor_calibration_cb)(void *user_data);
 /**
  * @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 minus Gx on the x-axis in [m/s^2]
  * @param[in] y             The acceleration minus Gy on the y-axis in [m/s^2]
@@ -176,7 +182,7 @@ typedef void (*sensor_calibration_cb)(void *user_data);
  * @see sensor_accelerometer_set_cb()
  * @see sensor_accelerometer_unset_cb()
  */
-typedef void (*sensor_accelerometer_event_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);
 /**
  * @}
@@ -194,6 +200,7 @@ typedef void (*sensor_accelerometer_event_cb)(
  * 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
@@ -203,7 +210,7 @@ typedef void (*sensor_accelerometer_event_cb)(
  * @see sensor_gyroscope_set_cb()
  * @see sensor_gyroscope_unset_cb()
  */
-typedef void (*sensor_gyroscope_event_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);
 /**
  * @}
@@ -221,7 +228,7 @@ typedef void (*sensor_gyroscope_event_cb)(
  * You should use lux between min and max values obtained \n
  * with #sensor_get_spec().
  *
- * @param[in] accuracy      The accuracy of @a level, @a y, and @a z values
+ * @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
@@ -229,8 +236,7 @@ typedef void (*sensor_gyroscope_event_cb)(
  * @see sensor_light_set_cb()
  * @see sensor_light_unset_cb()
  */
-typedef void (*sensor_light_event_cb)(
-               sensor_data_accuracy_e accuracy, float lux, void *user_data);
+typedef void (*sensor_light_event_cb)( unsigned long long timestamp, float lux, void *user_data);
 /**
  * @}
  */
@@ -245,6 +251,7 @@ typedef void (*sensor_light_event_cb)(
  *
  * @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
@@ -254,7 +261,7 @@ typedef void (*sensor_light_event_cb)(
  * @see sensor_magnetic_set_cb()
  * @see sensor_magnetic_unset_cb()
  */
-typedef void (*sensor_magnetic_event_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);
 /**
  * @}
@@ -270,6 +277,7 @@ typedef void (*sensor_magnetic_event_cb)(
  *
  * @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 x, @a y, and @a z 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
@@ -282,7 +290,7 @@ typedef void (*sensor_magnetic_event_cb)(
  * @see sensor_orientation_set_cb()
  * @see sensor_orientation_unset_cb()
  */
-typedef void (*sensor_orientation_event_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);
 /**
  * @}
@@ -296,13 +304,14 @@ typedef void (*sensor_orientation_event_cb)(
 /**
  * @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
+ * @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)(sensor_data_accuracy_e accuracy, float distance, void *user_data);
+typedef void (*sensor_proximity_event_cb)( unsigned long long timestamp, float distance, void *user_data);
 /**
  * @}
  */
@@ -318,13 +327,14 @@ typedef void (*sensor_proximity_event_cb)(sensor_data_accuracy_e accuracy, float
  * @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) (sensor_motion_snap_e snap, void *user_data);
+typedef void (*sensor_motion_snap_event_cb) ( unsigned long long timestamp, sensor_motion_snap_e snap, void *user_data);
 /**
  * @}
  */
@@ -338,13 +348,14 @@ typedef void (*sensor_motion_snap_event_cb) (sensor_motion_snap_e snap, void *us
 /**
  * @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) (sensor_motion_shake_e shake, void *user_data);
+typedef void (*sensor_motion_shake_event_cb) ( unsigned long long timestamp, sensor_motion_shake_e shake, void *user_data);
 /**
  * @}
  */
@@ -358,12 +369,13 @@ typedef void (*sensor_motion_shake_event_cb) (sensor_motion_shake_e shake, void
 /**
  * @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) (void *user_data);
+typedef void (*sensor_motion_doubletap_event_cb) ( unsigned long long timestamp, void *user_data);
 /**
  * @}
  */
@@ -378,6 +390,7 @@ typedef void (*sensor_motion_doubletap_event_cb) (void *user_data);
  * @brief Called when a panning tap 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
@@ -385,7 +398,7 @@ typedef void (*sensor_motion_doubletap_event_cb) (void *user_data);
  * @see sensor_motion_panning_set_cb()
  * @see sensor_motion_panning_unset_cb()
  */
-typedef void (*sensor_motion_panning_event_cb) (int x, int y, void *user_data);
+typedef void (*sensor_motion_panning_event_cb) ( unsigned long long timestamp, int x, int y, void *user_data);
 /**
  * @}
  */
@@ -404,12 +417,13 @@ typedef void (*sensor_motion_panning_event_cb) (int x, int y, void *user_data);
  * 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) (void *user_data);
+typedef void (*sensor_motion_facedown_event_cb) ( unsigned long long timestamp, void *user_data);
 /**
  * @}
  */
@@ -443,6 +457,8 @@ int sensor_is_supported(sensor_type_e type, bool *supported);
  * @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
@@ -454,7 +470,7 @@ int sensor_is_supported(sensor_type_e type, bool *supported);
  *
  * @pre #sensor_is_supported()
  */
-int sensor_get_spec(sensor_type_e type, float *max, float *min, float *resolution);
+int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float *max, float *min, float *resolution);
 
 
 /**
@@ -534,6 +550,93 @@ int sensor_start(sensor_h sensor, sensor_type_e type);
  */
 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]   type         The sensor type
+ * @param[in]   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_set(sensor_type_e type, bool enable);
+
+/**
+ * @brief Set the awaken behavior from specific sensor.
+ *
+ * @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_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]   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_awake_cb callback, void* user_data);
+
+/**
+ * @brief Unset the callback that called when device awaken.
+ * 
+ * @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();
 
 /**
  * @}
@@ -581,6 +684,22 @@ int sensor_accelerometer_set_cb(sensor_h sensor, int interval_ms, sensor_acceler
  */
 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.
@@ -646,6 +765,22 @@ int sensor_gyroscope_set_cb(sensor_h sensor, int interval_ms, sensor_gyroscope_e
 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.
  *
@@ -710,6 +845,22 @@ int sensor_light_set_cb(sensor_h sensor, int interval_ms, sensor_light_event_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
@@ -717,7 +868,6 @@ int sensor_light_unset_cb(sensor_h sensor);
  * with #sensor_get_spec().
  *
  * @param[in]   sensor      The sensor handle
- * @param[out]  accuracy    The accuracy of this data
  * @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
  *
@@ -729,7 +879,7 @@ int sensor_light_unset_cb(sensor_h sensor);
  * @see #sensor_data_accuracy_e
  * @see sensor_start()
  */
-int sensor_light_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *lux);
+int sensor_light_read_data(sensor_h sensor, float *lux);
 
 /**
  * @}
@@ -776,6 +926,22 @@ int sensor_magnetic_set_cb(sensor_h sensor, int interval_ms, sensor_magnetic_eve
 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.
@@ -915,6 +1081,22 @@ int sensor_orientation_set_calibration_cb(sensor_h sensor, sensor_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
@@ -983,13 +1165,28 @@ int sensor_proximity_set_cb(sensor_h sensor, int interval_ms, sensor_proximity_e
 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]  accuracy    The accuracy of this data
  * @param[out]  distance    The distance measured in centemeters
  *
  * @return      0 on success, otherwise a negative error value
@@ -1000,7 +1197,7 @@ int sensor_proximity_unset_cb(sensor_h sensor);
  * @pre In order to read sensor data, an application should call sensor_start().
  * @see sensor_start()
  */
-int sensor_proximity_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *distance);
+int sensor_proximity_read_data(sensor_h sensor, float *distance);
 /**
  * @}
  *
@@ -1214,11 +1411,416 @@ int sensor_motion_facedown_set_cb(sensor_h sensor, sensor_motion_facedown_event_
  *
  * @see sensor_motion_facedown_set_cb()
  */
+
 int sensor_motion_facedown_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_GRAVITY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called when an gravity event occurs.
+ *
+ * @param[in] accuracy      The accuracy of @a x, @a y, and @a z values
+ * @param[in] x             m/s^2
+ * @param[in] y             m/s^2
+ * @param[in] z             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_rotation_vector_set_cb().
+ *
+ * @see sensor_rotation_vector_set_cb()
+ * @see sensor_rotation_vector_unset_cb()
+ */
+typedef void (*sensor_gravity_event_cb)(
+               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_accelerometer_event_cb() will be invoked.
+ *
+ * @see sensor_accelerometer_event_cb()
+ * @see sensor_accelerometer_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_rotation_vector_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             m/s^2
+ * @param[in] y             m/s^2
+ * @param[in] z             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_gravity_read_data(sensor_h sensor, sensor_data_accuracy_e* accuracy, float* x, float* y, float* z);
+
+
+/**
+ * @}
+ */
+
+/**
+ * @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);
+
+/**
+ * @}
+ */
+
+
+/**
+ * @}
+ *
  * @}
  */
 
index 8b66a9c..6d81d23 100644 (file)
@@ -1,9 +1,9 @@
 Name:       capi-system-sensor
 Summary:    A Sensor library in TIZEN C API
-Version:    0.1.0
-Release:    9
+Version: 0.1.0
+Release:    10
 Group:      TO_BE/FILLED_IN
-License:    Apache-2.0
+License:    Apache 2.0
 Source0:    %{name}-%{version}.tar.gz
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
index c8c433a..6fa5ef0 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <sys/time.h>
 
 #include <sensor.h>
 #include <sensor_accel.h>
@@ -100,6 +101,8 @@ static char* _DONT_USE_THIS_ARRAY_DIRECTLY[] = {
 #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,
@@ -205,6 +208,9 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
     sensor_panning_data_t *panning_data = NULL;
        int motion = 0;
     int nid = 0;
+
+       struct timeval sv;
+       unsigned long long motion_time_stamp = 0;
 //    bool proximity = 0;
 
        sensor_h sensor = (sensor_h)udata;
@@ -292,25 +298,34 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
        switch(event_type)
        {
                case MOTION_ENGINE_EVENT_SNAP:
-                       ((sensor_motion_snap_event_cb)sensor->cb_func[nid])(motion, sensor->cb_user_data[nid]);
+                       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:
-                       ((sensor_motion_shake_event_cb)sensor->cb_func[nid])(motion, sensor->cb_user_data[nid]);
+                       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:
-                       ((sensor_motion_doubletap_event_cb)sensor->cb_func[nid])(sensor->cb_user_data[nid]);
+                       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:
-                       ((sensor_motion_facedown_event_cb)sensor->cb_func[nid])(sensor->cb_user_data[nid]);
+                       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:
-                       ((sensor_motion_panning_event_cb)sensor->cb_func[nid])(panning_data->x, panning_data->y, 
-                sensor->cb_user_data[nid]);
+                       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 ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME :
                        for(i=0; i<data_num; i++){
                                ((sensor_accelerometer_event_cb)sensor->cb_func[nid])
-                                       (_ACCU(data[i].data_accuracy), 
+                                       (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]);
                        }
@@ -318,7 +333,7 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
                case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
                        for(i=0; i<data_num; i++){
                                ((sensor_magnetic_event_cb)sensor->cb_func[nid])
-                                       (_ACCU(data[i].data_accuracy), 
+                                       (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]);
                        }
@@ -326,7 +341,7 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
                case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
                        for(i=0; i<data_num; i++){
                                ((sensor_orientation_event_cb)sensor->cb_func[nid])
-                                       (_ACCU(data[i].data_accuracy), 
+                                       (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]);
                        }
@@ -334,7 +349,7 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
                case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
                        for(i=0; i<data_num; i++){
                                ((sensor_gyroscope_event_cb)sensor->cb_func[nid])
-                                       (_ACCU(data[i].data_accuracy), 
+                                       (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]);
                        }
@@ -342,7 +357,7 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
                case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
                        for(i=0; i<data_num; i++){
                                ((sensor_light_event_cb)sensor->cb_func[nid])
-                                       (_ACCU(data[i].data_accuracy)
+                                       (data[i].time_stamp
                                         data[i].values[0], 
                                         sensor->cb_user_data[nid]);
                        }
@@ -350,7 +365,7 @@ static void _sensor_callback (unsigned int event_type, sensor_event_data_t* even
                case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
                        for(i=0; i<data_num; i++){
                                ((sensor_proximity_event_cb)sensor->cb_func[nid])
-                                       (_ACCU(data[i].data_accuracy)
+                                       (data[i].time_stamp
                                         data[i].values[0], 
                                         sensor->cb_user_data[nid]);
                        }
@@ -373,22 +388,31 @@ int sensor_is_supported(sensor_type_e type, bool* supported)
     return SENSOR_ERROR_NONE;
 }
 
-int sensor_get_spec(sensor_type_e type, float* max, float* min, float* resolution)
+int sensor_get_spec(sensor_type_e type, char** vendor, char** model, float* max, float* min, float* resolution)
 {
-    sensor_data_properties_t properties;
-    
+    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], &properties) < 0)
+    if(sf_get_data_properties(_DTYPE[type], &data_properties) < 0)
         RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
 
-       *max = properties.sensor_max_range;
-       *min = properties.sensor_min_range;
-       *resolution = properties.sensor_resolution;
+       if(sf_get_properties(_TYPE[type], &properties) < 0)
+        RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
+
+       if(vendor != NULL)
+               *vendor = properties.sensor_vendor;
+       if(model != NULL)
+               *model = properties.sensor_name;
+
+       *max = data_properties.sensor_max_range;
+       *min = data_properties.sensor_min_range;
+       *resolution = data_properties.sensor_resolution;
 
        DEBUG_PRINTF("success get %s's format max=%f, min=%f, res=%f\n", TYPE_NAME(type), *max, *min, *resolution);
 
@@ -821,10 +845,10 @@ int sensor_gyroscope_read_data     (sensor_h handle, sensor_data_accuracy_e* acc
        return SENSOR_ERROR_NONE;
 }
 
-int sensor_light_read_data         (sensor_h handle, sensor_data_accuracy_e* accuracy, float* lux)
+int sensor_light_read_data         (sensor_h handle, float* lux)
 {
        float values[1] = {0};
-       int err = _sensor_read_data(handle, SENSOR_LIGHT, accuracy, values, 1);
+       int err = _sensor_read_data(handle, SENSOR_LIGHT, NULL, values, 1);
     if(err < 0) return err;
 
     if(lux == NULL)
@@ -835,10 +859,10 @@ int sensor_light_read_data         (sensor_h handle, sensor_data_accuracy_e* acc
        return SENSOR_ERROR_NONE;
 }
 
-int sensor_proximity_read_data     (sensor_h handle, sensor_data_accuracy_e* accuracy, float* distance)
+int sensor_proximity_read_data     (sensor_h handle, float* distance)
 {
        float values[1] = {0};
-    int err = _sensor_read_data(handle, SENSOR_PROXIMITY, accuracy, values, 1);
+    int err = _sensor_read_data(handle, SENSOR_PROXIMITY, NULL, values, 1);
     if(err < 0) return err;
 
     if(distance == NULL)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..1f8cbcd
--- /dev/null
@@ -0,0 +1,54 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-sensor")
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+INCLUDE_DIRECTORIES(../include)
+
+#ADD_EXECUTABLE("system-sensor" system-sensor.c)
+#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS})
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    MESSAGE("${src_name}")
+    ADD_EXECUTABLE(${src_name} ${src})
+    TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS} ${fw_name} -lm)
+ENDFOREACH()
+
+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/test/accelerometer-gravity-with-linear-acceleration.c b/test/accelerometer-gravity-with-linear-acceleration.c
new file mode 100644 (file)
index 0000000..d3ec69c
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+
+static GMainLoop *mainloop;
+
+const float Alpha = 0.8;
+
+struct three_axis_s{
+    float x,y,z;
+};
+
+struct three_axis_s gravitys = {0,0,0};
+struct three_axis_s linear_accelation = {0,0,0};
+
+static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+    gravitys.x = Alpha * gravitys.x + ( 1 - Alpha ) * x;
+    gravitys.y = Alpha * gravitys.y + ( 1 - Alpha ) * y;
+    gravitys.z = Alpha * gravitys.z + ( 1 - Alpha ) * z;
+
+    linear_accelation.x = x - gravitys.x;
+    linear_accelation.y = y - gravitys.y;
+    linear_accelation.z = z - gravitys.z;
+
+       printf("[gravitys x=%f y=%f z=%f] [linear acc x=%f y=%f z=%f]\n", 
+            gravitys.x, gravitys.y, gravitys.z, 
+            linear_accelation.x, linear_accelation.y, linear_accelation.z);
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int type = SENSOR_ACCELEROMETER;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+               printf("max=%f, min=%f, res=%f\n", max, min, res);
+    }else{
+        printf("Error!!!!\n");
+    }
+
+       sensor_create(&handle);
+
+    sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, NULL);
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+    sensor_accelerometer_unset_cb(handle);
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+       sensor_destroy(handle);
+       return 0;
+}
diff --git a/test/gyroscope-calc-anger.c b/test/gyroscope-calc-anger.c
new file mode 100644 (file)
index 0000000..9dfa9b7
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+#include <time.h>
+
+struct xyz_axis {
+    float x,y,z;
+};
+
+static struct xyz_axis angles = {0,0,0};
+static time_t timestamp = 0;
+
+static GMainLoop *mainloop;
+
+static void test_gyroscope_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+    time_t current_timestamp = time(0);
+    if(timestamp != 0){
+        const float dT = difftime(current_timestamp, timestamp);
+        angles.x += x * dT;
+        angles.y += y * dT;
+        angles.z += z * dT;
+        printf("angle x=%f y=%f z=%f\n", angles.x, angles.y, angles.z);
+    }
+    timestamp = current_timestamp;
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int type = SENSOR_GYROSCOPE;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+               printf("max=%f, min=%f, res=%f\n", max, min, res);
+    }else{
+        printf("Error!!!!\n");
+    }
+
+       sensor_create(&handle);
+
+    sensor_gyroscope_set_cb(handle, 0, test_gyroscope_cb, NULL);
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+    sensor_gyroscope_unset_cb(handle);
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+       sensor_destroy(handle);
+       return 0;
+}
diff --git a/test/rotation.c b/test/rotation.c
new file mode 100644 (file)
index 0000000..2d40b49
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+#include <math.h>
+
+#define RADIAN_VALUE (57.2957)
+#define PITCH_MIN       35
+#define PITCH_MAX       145
+
+
+static GMainLoop *mainloop;
+
+const float Alpha = 0.8;
+
+struct three_axis_s{
+    float x,y,z;
+};
+
+struct three_axis_s gravitys = {0,0,0};
+struct three_axis_s linear_accelation = {0,0,0};
+
+enum {
+    ROTATE_0,
+    ROTATE_90,
+    ROTATE_180,
+    ROTATE_270,
+    ROTATE_ERROR
+};
+
+static int current_rotate = -1;
+
+static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+    double atan_v, norm_z, raw_z;
+    int acc_theta, acc_pitch;
+    int rotate;
+
+    atan_v = atan2(y, x);
+    acc_theta = (int)(atan_v * (RADIAN_VALUE) + 270)%360;
+    raw_z = (double)(z/(0.004 * 9.81));
+
+    if(raw_z > 250){
+        norm_z = 1.0;
+    }else if(raw_z < -250){
+        norm_z = -1.0;
+    }else{
+        norm_z = ((double)raw_z)/250;
+    }
+
+    acc_pitch = (int)( acos(norm_z) *(RADIAN_VALUE));
+
+    if( (acc_pitch>35) && (acc_pitch<145) ) {
+        if ((acc_theta >= 315 && acc_theta <=359) || (acc_theta >=0 && acc_theta < 45)){
+            rotate = ROTATE_0;
+        }
+        else if(acc_theta >= 45 && acc_theta < 135){
+            rotate = ROTATE_90;
+        }
+        else if(acc_theta >=135 && acc_theta < 225){
+            rotate = ROTATE_180;
+        }
+        else if(acc_theta >=225 && acc_theta < 315){
+            rotate = ROTATE_270;
+        }
+        else {
+            rotate = ROTATE_ERROR;
+        }
+    }else{
+        rotate = ROTATE_ERROR;
+    }
+
+    if(rotate != ROTATE_ERROR && current_rotate != rotate){
+        current_rotate = rotate;
+        printf("rotation is %d\n", rotate * 90);
+    }
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int type = SENSOR_ACCELEROMETER;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+               printf("max=%f, min=%f, res=%f\n", max, min, res);
+    }else{
+        printf("Error!!!!\n");
+    }
+
+       sensor_create(&handle);
+
+    sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, NULL);
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+    sensor_accelerometer_unset_cb(handle);
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+       sensor_destroy(handle);
+       return 0;
+}
diff --git a/test/supported-sensor.c b/test/supported-sensor.c
new file mode 100644 (file)
index 0000000..739dadc
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sensors.h>
+
+static char* TYPE_NAME[] = {
+       "ACCELEROMETER",
+       "MAGNETIC",
+       "ORIENTATION",
+       "GYROSCOPE",
+       "LIGHT",
+       "PROXIMITY",
+       "MOTION_SNAP",
+       "MOTION_SHAKE",
+       "MOTION_DOUBLETAP",
+       "MOTION_PANNING",
+       "MOTION_FACEDOWN"
+};
+
+int main(int argc, char *argv[])
+{
+       int err;
+    sensor_type_e type;
+    bool is_supported;
+    char* supported_msg;
+       
+    for(type=0; type<=SENSOR_MOTION_FACEDOWN; type++){
+        err = sensor_is_supported(type, &is_supported);
+
+        supported_msg = err < 0 ? "error" : (is_supported ? "support" : "not support");
+
+        printf("%d : %s [%s]\n", type, TYPE_NAME[type], supported_msg);
+    }
+    return 0;
+
+}
diff --git a/test/system-sensor.c b/test/system-sensor.c
new file mode 100644 (file)
index 0000000..5a29ed7
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+
+static GMainLoop *mainloop;
+
+static char* TYPE_NAME[] = {
+       "ACCELEROMETER",
+       "MAGNETIC",
+       "ORIENTATION",
+       "GYROSCOPE",
+       "LIGHT",
+       "PROXIMITY",
+       "MOTION_SNAP",
+       "MOTION_SHAKE",
+       "MOTION_DOUBLETAP",
+       "MOTION_PANNING",
+       "MOTION_FACEDOWN"
+};
+
+static char* SNAP[] = {
+       "NONE",
+    "LEFT",
+    "RIGHT"
+};
+
+static char* SHAKE[] = {
+       "NONE",
+       "DETECTION",
+       "CONTINUING",
+       "FINISH",
+       "BREAK"
+};
+
+static void test_calibration_cb(void *user_data)
+{
+    char* xx = (char*)user_data;
+       printf("%s sensor is calibration needed!!!!!!!!!!!!!!!!!!\n", xx);
+}
+
+static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+       printf("ACCELEROMETER sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
+}
+
+static void test_magnetic_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+       printf("MAGNETIC sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
+}
+
+static void test_orientation_cb(sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data)
+{
+       printf("ORIENTATION sensor acc=%d azimuth=%f pitch=%f roll=%f\n", accuracy, azimuth, pitch, roll);
+}
+
+static void test_gyroscope_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+       printf("GYROSCOPE sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
+}
+
+static void test_light_cb(sensor_data_accuracy_e accuracy, float lux, void *user_data)
+{
+       printf("LIGHT sensor acc=%d lux=%f\n", accuracy, lux);
+}
+
+static void test_proximity_cb(sensor_data_accuracy_e accuracy, float distance, void *user_data)
+{
+       printf("PROXIMITY sensor distance = %fcm\n", distance);
+}
+
+static void test_motion_snap_cb        (sensor_motion_snap_e snap, void *user_data)
+{
+       printf("MOTION_SNAP [%s]\n", SNAP[snap]);
+}
+
+static void test_motion_shake_cb       (sensor_motion_shake_e shake, void *user_data)
+{
+       printf("MOTION_SHAKE [%s]\n", SHAKE[shake]);
+}
+
+static void test_motion_doubletap_cb   (void *user_data)
+{
+       printf("MOTION_DOUBLETAP \n");
+}
+
+static void test_motion_panning_cb (int x, int y, void *user_data)
+{
+       printf("MOTION_PANNING x=[%5d] y=[%5d]\n", x, y);
+}
+
+static void test_motion_facedown_cb (void *user_data)
+{
+       printf("MOTION_FACEDOWN \n");
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int i;
+       int type;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(argc < 2)
+       {
+               printf("input sensor type\n");
+               for(i=0; i<=SENSOR_MOTION_FACEDOWN; i++){
+                       printf("%d : %s\n", i, TYPE_NAME[i]);
+               }
+               return 0;
+       }
+
+       type = atoi(argv[1]);
+    /*
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+    */
+
+    if(type < 0 || type > SENSOR_MOTION_FACEDOWN)
+               printf("unknown sensor!\n");
+    else
+               printf("selected sensor is (%d)%s\n", type, TYPE_NAME[type]);
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+
+    if(type < SENSOR_MOTION_SNAP){
+        if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+            printf("max=%f, min=%f, res=%f\n", max, min, res);
+        }else{
+            printf("Error!!!!\n");
+        }
+    }
+
+       sensor_create(&handle);
+
+       switch(type){
+               case SENSOR_ACCELEROMETER:
+                       sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MAGNETIC:
+                       sensor_magnetic_set_cb(handle, 0, test_magnetic_cb, TYPE_NAME[type]);
+                       sensor_magnetic_set_calibration_cb(handle, test_calibration_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_ORIENTATION:
+                       sensor_orientation_set_cb(handle, 0, test_orientation_cb, TYPE_NAME[type]);
+                       sensor_orientation_set_calibration_cb(handle, test_calibration_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_GYROSCOPE:
+                       sensor_gyroscope_set_cb(handle, 0, test_gyroscope_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_LIGHT:
+                       sensor_light_set_cb(handle, 0, test_light_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_PROXIMITY:
+                       sensor_proximity_set_cb(handle, 0, test_proximity_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_SNAP:
+                       sensor_motion_snap_set_cb(handle, test_motion_snap_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_SHAKE:
+                       sensor_motion_shake_set_cb(handle, test_motion_shake_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_DOUBLETAP:
+                       sensor_motion_doubletap_set_cb(handle, test_motion_doubletap_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_PANNING:
+            sensor_motion_panning_set_cb(handle, test_motion_panning_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_FACEDOWN:
+            sensor_motion_facedown_set_cb(handle, test_motion_facedown_cb, TYPE_NAME[type]);
+                       break;
+               default:
+                       goto _ending;
+       }
+
+    printf("Success register callback \n");
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+       switch(type){
+               case SENSOR_ACCELEROMETER:
+            sensor_accelerometer_unset_cb(handle);
+                       break;
+               case SENSOR_MAGNETIC:
+            sensor_magnetic_unset_calibration_cb(handle);
+            sensor_magnetic_unset_cb(handle);
+                       break;
+               case SENSOR_ORIENTATION:
+                       sensor_orientation_unset_calibration_cb(handle);
+            sensor_orientation_unset_cb(handle);
+                       break;
+               case SENSOR_GYROSCOPE:
+            sensor_gyroscope_unset_cb(handle);
+                       break;
+               case SENSOR_LIGHT:
+            sensor_light_unset_cb(handle);
+                       break;
+               case SENSOR_PROXIMITY:
+            sensor_proximity_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_SNAP:
+            sensor_motion_snap_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_SHAKE:
+            sensor_motion_shake_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_DOUBLETAP:
+            sensor_motion_doubletap_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_PANNING:
+            sensor_motion_panning_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_FACEDOWN:
+            sensor_motion_facedown_unset_cb(handle);
+                       break;
+
+               default:
+                       goto _ending;
+       }
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+_ending:
+       sensor_destroy(handle);
+       return 0;
+}