From: Hongkuk, Son Date: Tue, 6 Oct 2015 10:34:27 +0000 (+0900) Subject: capi-sensor: sync with tizen_2.4 X-Git-Tag: submit/tizen/20151113.112518~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=176bac2e706cce3089c0cc8014da04a06f730074;p=platform%2Fcore%2Fapi%2Fsensor.git capi-sensor: sync with tizen_2.4 Signed-off-by: Hongkuk, Son Change-Id: Iccbfdab416b696127cc89cad222076f13cd12c62 --- diff --git a/doc/sensor_doc.h b/doc/sensor_doc.h index bf3b708..73f26b7 100644 --- a/doc/sensor_doc.h +++ b/doc/sensor_doc.h @@ -47,9 +47,13 @@ * - http://tizen.org/feature/sensor.rotation_vector\n * - http://tizen.org/feature/sensor.gravity\n * - http://tizen.org/feature/sensor.heart_rate_monitor\n - * - http://tizen.org/feature/sensor.hrm_led_green\n - * - http://tizen.org/feature/sensor.hrm_led_ir\n - * - http://tizen.org/feature/sensor.hrm_led_red\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\n + * - http://tizen.org/feature/sensor.gyroscope.uncalibrated\n + * - http://tizen.org/feature/sensor.magnetometer.uncalibrated\n + * - http://tizen.org/feature/sensor.gyroscope_rotation_vector\n + * - http://tizen.org/feature/sensor.geomagnetic_rotation_vector\n * * It is recommended to design feature related codes in your application for reliability.\n * @@ -85,9 +89,13 @@ * - http://tizen.org/feature/sensor.rotation_vector\n * - http://tizen.org/feature/sensor.gravity\n * - http://tizen.org/feature/sensor.heart_rate_monitor\n - * - http://tizen.org/feature/sensor.hrm_led_green\n - * - http://tizen.org/feature/sensor.hrm_led_ir\n - * - http://tizen.org/feature/sensor.hrm_led_red\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\n + * - http://tizen.org/feature/sensor.gyroscope.uncalibrated\n + * - http://tizen.org/feature/sensor.magnetometer.uncalibrated\n + * - http://tizen.org/feature/sensor.gyroscope_rotation_vector\n + * - http://tizen.org/feature/sensor.geomagnetic_rotation_vector\n * * It is recommended to design feature related codes in your application for reliability.\n * @@ -122,9 +130,13 @@ * - http://tizen.org/feature/sensor.rotation_vector\n * - http://tizen.org/feature/sensor.gravity\n * - http://tizen.org/feature/sensor.heart_rate_monitor\n - * - http://tizen.org/feature/sensor.hrm_led_green\n - * - http://tizen.org/feature/sensor.hrm_led_ir\n - * - http://tizen.org/feature/sensor.hrm_led_red\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_green\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_ir\n + * - http://tizen.org/feature/sensor.heart_rate_monitor.led_red\n + * - http://tizen.org/feature/sensor.gyroscope.uncalibrated\n + * - http://tizen.org/feature/sensor.magnetometer.uncalibrated\n + * - http://tizen.org/feature/sensor.gyroscope_rotation_vector\n + * - http://tizen.org/feature/sensor.geomagnetic_rotation_vector\n * * It is recommended to design feature related codes in your application for reliability.\n * diff --git a/include/sensor.h b/include/sensor.h index 1d347b1..e884c63 100644 --- a/include/sensor.h +++ b/include/sensor.h @@ -45,7 +45,7 @@ extern "C" /** * @brief The sensor handle. * @details This handle indicates a specific sensor itself. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef void* sensor_h; @@ -53,7 +53,7 @@ typedef void* sensor_h; /** * @brief The listener handle. * @details This listener is an event listener used to receive sensor data asynchronously. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct sensor_listener_s *sensor_listener_h; @@ -61,7 +61,7 @@ typedef struct sensor_listener_s *sensor_listener_h; /** * @brief The structure type containing information of an event. * @details It holds information such as timestamp, accuracy, and sensor values. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks If you use proximity sensor, see #sensor_proximity_e */ @@ -75,7 +75,7 @@ typedef struct /** * @brief Enumeration for sensor data accuracy. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -89,7 +89,7 @@ typedef enum /** * @brief Enumeration for sensor error. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -105,7 +105,7 @@ typedef enum /** * @brief Enumeration for proximity sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -116,7 +116,7 @@ typedef enum /** * @brief Enumeration for sensor types. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -134,21 +134,21 @@ typedef enum SENSOR_ULTRAVIOLET, /**< Ultraviolet sensor */ SENSOR_TEMPERATURE, /**< Temperature sensor */ SENSOR_HUMIDITY, /**< Humidity sensor */ - SENSOR_HRM, /**< Heart Rate Monitor sensor */ - SENSOR_HRM_LED_GREEN, /**< HRM (LED Green) sensor */ - SENSOR_HRM_LED_IR, /**< HRM (LED IR) sensor */ - SENSOR_HRM_LED_RED, /**< HRM (LED RED) sensor */ - SENSOR_GYROSCOPE_UNCALIBRATED, /**< Uncalibrated Gyroscope sensor */ - SENSOR_GEOMAGNETIC_UNCALIBRATED, /**< Uncalibrated Geomagnetic sensor */ - SENSOR_GYROSCOPE_ROTATION_VECTOR, /**< Gyroscope-based Rotation Vector sensor */ - SENSOR_GEOMAGNETIC_ROTATION_VECTOR, /**< Geomagnetic-based Rotation Vector sensor */ + SENSOR_HRM, /**< Heart Rate Monitor sensor @if MOBILE (Since Tizen 2.3.1) @endif */ + SENSOR_HRM_LED_GREEN, /**< HRM (LED Green) sensor @if MOBILE (Since Tizen 2.3.1) @endif */ + SENSOR_HRM_LED_IR, /**< HRM (LED IR) sensor @if MOBILE (Since Tizen 2.3.1) @endif */ + SENSOR_HRM_LED_RED, /**< HRM (LED RED) sensor @if MOBILE (Since Tizen 2.3.1) @endif */ + SENSOR_GYROSCOPE_UNCALIBRATED, /**< Uncalibrated Gyroscope sensor (Since Tizen 2.4) */ + SENSOR_GEOMAGNETIC_UNCALIBRATED, /**< Uncalibrated Geomagnetic sensor (Since Tizen 2.4) */ + SENSOR_GYROSCOPE_ROTATION_VECTOR, /**< Gyroscope-based rotation vector sensor (Since Tizen 2.4) */ + SENSOR_GEOMAGNETIC_ROTATION_VECTOR, /**< Geomagnetic-based rotation vector sensor (Since Tizen 2.4) */ SENSOR_LAST, /**< End of sensor enum values */ SENSOR_CUSTOM = 10000 /**< Custom sensor */ } sensor_type_e; /** * @brief Enumeration for sensor options. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ #ifndef __SENSOR_COMMON_H__ typedef enum @@ -163,7 +163,7 @@ typedef enum /** * @brief Checks whether a given sensor type is available on a device. * @details Availability of a sensor should be checked first because this sensor may not be supported on the device. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED) * the privilege should be set to, %http://tizen.org/privilege/healthinfo. * @@ -182,7 +182,7 @@ int sensor_is_supported(sensor_type_e type, bool *supported); /** * @brief Gets a specific sensor handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks For getting a handle of HRM Sensor(including HRM_LED_GREEN, HRM_LED_IR and HRM_LED_RED) * the privilege should be set to, %http://tizen.org/privilege/healthinfo. * @@ -200,7 +200,7 @@ int sensor_get_default_sensor(sensor_type_e type, sensor_h *sensor); /** * @brief Gets a sensor list. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks If you want to get a handle list of all sensors, * use SENSOR_ALL type in sensor_type_e. * @remarks The caller should explicitly free this list. @@ -220,7 +220,7 @@ int sensor_get_sensor_list(sensor_type_e type, sensor_h **list, int *sensor_coun /** * @brief Called when a sensor event occurs. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[in] event The event information @@ -234,7 +234,7 @@ typedef void (*sensor_event_cb)(sensor_h sensor, sensor_event_s *event, void *da /** * @brief Creates a sensor listener. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks You must release @a listener using sensor_destroy_listener(). * @@ -258,7 +258,7 @@ int sensor_create_listener(sensor_h sensor, sensor_listener_h *listener); /** * @brief Destroys the sensor handle and releases all its resources. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks After this function is called, the attached sensor is detached and * the corresponding sensor connection is released. @@ -281,7 +281,7 @@ int sensor_destroy_listener(sensor_listener_h listener); * @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. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @@ -304,7 +304,7 @@ int sensor_listener_start(sensor_listener_h listener); * * @details The given @a type event will not occur any more and the callback functions also won't be called. * - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @@ -321,11 +321,12 @@ int sensor_listener_stop(sensor_listener_h listener); /** * @brief Registers a callback function to be invoked when a sensor event occurs. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @param[in] interval_ms The interval at which sensor events are delivered (in milliseconds) \n - * If @a rate is zero, it uses the default value(100ms) + * If @a rate is zero, it uses the default value(100ms) \n + * Min value is 10ms, Max value is 1000ms(10ms ~ 1000ms) * @param[in] callback The callback function to register * @param[in] data The user data to be passed to the callback function * @@ -344,7 +345,7 @@ int sensor_listener_set_event_cb(sensor_listener_h listener, unsigned int interv /** * @brief Unregisters the sensor callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @@ -366,7 +367,7 @@ int sensor_listener_unset_event_cb(sensor_listener_h listener); * @details When something is artificially influencing, such as ferrous metal objects or * electromagnetic fields (car electrical systems, automobile engines, steel pitons, and so on.), this callback is called. * One way of implementing this callback is to instruct a user to make big 8-like gestures with the device. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[in] timestamp The time in milliseconds at which the event happened @@ -377,7 +378,7 @@ typedef void (*sensor_accuracy_changed_cb)(sensor_h sensor, unsigned long long t /** * @brief Registers an accuracy callback function to be invoked when the accuracy of a sensor has changed. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @param[in] callback The callback function to register @@ -398,7 +399,7 @@ int sensor_listener_set_accuracy_cb(sensor_listener_h listener, sensor_accuracy_ /** * @brief Unregisters the sensor accuracy changed callback function. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @@ -416,7 +417,7 @@ int sensor_listener_unset_accuracy_cb(sensor_listener_h listener); /** * @brief Gets sensor data. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @param[out] event The event information @@ -434,11 +435,12 @@ int sensor_listener_read_data(sensor_listener_h listener, sensor_event_s *event) /** * @brief Changes the interval at sensor measurements. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @param[in] interval_ms The interval at which sensor events are delivered (in milliseconds) \n - * If @a rate is zero, it uses the default value(100ms) + * If @a rate is zero, it uses the default value(100ms) \n + * Min value is 10ms, Max value is 1000ms(10ms ~ 1000ms) * * @return @c 0 on success, * otherwise a negative error value @@ -452,7 +454,7 @@ int sensor_listener_set_interval(sensor_listener_h listener, unsigned int interv /** * @brief Changes the max batch latency at sensor measurements. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @param[in] max_batch_latency The latency at which sensor events are delivered (in milliseconds) @@ -470,7 +472,7 @@ int sensor_listener_set_max_batch_latency(sensor_listener_h listener, unsigned i /** * @brief Changes the option of the sensor. * @details If it is default, sensor data cannot be recieved when the LCD is off and in the power save mode. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] listener The listener handle * @param[in] option The sensor option @@ -495,7 +497,7 @@ int sensor_listener_set_option(sensor_listener_h listener, sensor_option_e optio /** * @brief Gets the name of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] name The name of the sensor @@ -511,7 +513,7 @@ int sensor_get_name(sensor_h sensor, char** name); /** * @brief Gets the vendor of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] vendor The vendor of the sensor @@ -527,7 +529,7 @@ int sensor_get_vendor(sensor_h sensor, char** vendor); /** * @brief Gets the type of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] type The type of the sensor @@ -543,7 +545,7 @@ int sensor_get_type(sensor_h sensor, sensor_type_e *type); /** * @brief Gets the minimum range of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] min_range The minimum range @@ -559,7 +561,7 @@ int sensor_get_min_range(sensor_h sensor, float *min_range); /** * @brief Gets the maximum range of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] max_range The maximum range @@ -575,7 +577,7 @@ int sensor_get_max_range(sensor_h sensor, float *max_range); /** * @brief Gets the resolution of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] resolution The resolution @@ -591,7 +593,7 @@ int sensor_get_resolution(sensor_h sensor, float *resolution); /** * @brief Gets the minimun interval of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] min_interval The minimum interval (in milliseconds) @@ -607,7 +609,7 @@ int sensor_get_min_interval(sensor_h sensor, int *min_interval); /** * @brief Gets the fifo count of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] fifo_count The fifo count @@ -623,7 +625,7 @@ int sensor_get_fifo_count(sensor_h sensor, int *fifo_count); /** * @brief Gets the maximum batch count of the sensor. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] sensor The sensor handle * @param[out] max_batch_count The maximum batch count @@ -647,7 +649,7 @@ int sensor_get_max_batch_count(sensor_h sensor, int *max_batch_count); /** * @brief Enumeration of the axis used in #sensor_util_remap_coordinate_system. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @see #sensor_util_remap_coordinate_system */ @@ -668,7 +670,7 @@ typedef enum * [0 m 0] = I * R * geomagnetic (m = magnitude of the 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 towards the 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 - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks Parameters Gx, Gy, and Gz can be obtained from the values returned by #SENSOR_GRAVITY. \n * Parameters Mx, My, and Mz can be obtained from the values returned by #SENSOR_MAGNETIC. @@ -706,7 +708,7 @@ int sensor_util_get_rotation_matrix(float Gx, float Gy, float Gz, * * @details Rotation vectors (Vx, Vy, Vz) can be obtained from #SENSOR_ROTATION_VECTOR. * It returns a 9 element rotation matrix in the array R. R must have length as 9. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] Vx The X-axis rotation vector * @param[in] Vy The Y-axis rotation vector @@ -725,7 +727,7 @@ int sensor_util_get_rotation_matrix_from_vector(float Vx, float Vy, float Vz, fl * @brief Rotates the supplied rotation matrix so that 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. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks inR and outR can be the same array, but this is not recommended for performance reasons. * This returns an error when X and Y define the same axis. @@ -746,7 +748,7 @@ int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, senso /** * @brief Computes the geomagnetic inclination angle in radians from the inclination matrix I returned by sensor_util_get_rotation_matrix(). - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @param[in] I The inclination matrix from sensor_util_get_rotation_matrix() * @param[out] inclination The geomagnetic inclination angle in radians @@ -768,7 +770,7 @@ int sensor_util_get_inclination(float I[], float* inclination); * - values[0]: azimuth, rotation around the Z axis. * - values[1]: pitch, rotation around the X axis. * - values[2]: roll, rotation around the Y axis. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks Parameter R must be an array of 9 floats from sensor_util_get_rotation_matrix() \n * Returned values are always arrays of 3 floats. @@ -793,7 +795,7 @@ int sensor_util_get_orientation(float R[], float values[]); * @details Given a current rotation matrix (R) and a previous rotation matrix (prevR), it computes * the rotation around the x,y, and z axes which transforms prevR to R. * It outputs a 3 element vector containing the x,y, and z angle change at indexes 0, 1, and 2 respectively. \n - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * * @remarks Each input matrix is a 3x3 matrix like this form: *
@@ -816,7 +818,7 @@ int sensor_util_get_angle_change(float R[], float prevR[], float angleChange[]);
 
 /**
  * @brief Gets the declination of the horizontal component of the magnetic field from true north, in degrees.
- * @since_tizen 2.3
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[in]  latitude     The latitude in geodetic coordinates
  * @param[in]  longitude    The longitude in geodetic coordinates
diff --git a/packaging/capi-system-sensor.spec b/packaging/capi-system-sensor.spec
index 8c1240f..b32f6cb 100644
--- a/packaging/capi-system-sensor.spec
+++ b/packaging/capi-system-sensor.spec
@@ -3,7 +3,7 @@ Summary:    A Sensor library in TIZEN C API
 Version:    0.1.18
 Release:    0
 Group:      System/API
-License:    Apache 2.0
+License:    Apache-2.0 and PD
 Source0:    %{name}-%{version}.tar.gz
 Source1:    capi-system-sensor.manifest
 
diff --git a/src/fusion_util.c b/src/fusion_util.c
index 2dc8f1b..3a47828 100644
--- a/src/fusion_util.c
+++ b/src/fusion_util.c
@@ -24,12 +24,12 @@ float clamp(float v)
 
 int getAngleChange(float *R, float *prevR, float *angleChange)
 {
-	if(R == NULL || prevR == NULL || angleChange == NULL)
+	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;
+	float rd1, rd4, rd6, rd7, rd8;
+	float ri0, ri1, ri2, ri3, ri4, ri5, ri6, ri7, ri8;
+	float pri0, pri1, pri2, pri3, pri4, pri5, pri6, pri7, pri8;
 
 	ri0 = R[0];
 	ri1 = R[1];
@@ -65,7 +65,7 @@ int getAngleChange(float *R, float *prevR, float *angleChange)
 }
 int quatToMatrix(float *quat, float *R)
 {
-	if(quat == NULL || R == NULL)
+	if (quat == NULL || R == NULL)
 		return -1;
 
 	float q0 = quat[0];
@@ -98,16 +98,16 @@ int quatToMatrix(float *quat, float *R)
 
 int matrixToQuat(float *mat, float *q)
 {
-	if(q == NULL || mat == NULL)
+	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] = 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]);
@@ -117,7 +117,7 @@ int matrixToQuat(float *mat, float *q)
 
 int getRotationMatrix(float *accel, float *geo, float *R, float *I)
 {
-	if(accel == NULL || geo == NULL || R == NULL || I == NULL)
+	if (accel == NULL || geo == NULL || R == NULL || I == NULL)
 		return -1;
 
 	float Ax = accel[0];
@@ -130,7 +130,7 @@ int getRotationMatrix(float *accel, float *geo, float *R, float *I)
 	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){
+	if (normH < 0.1f) {
 		return -1;
 	}
 	float invH = 1.0f / normH;
@@ -155,7 +155,7 @@ int getRotationMatrix(float *accel, float *geo, float *R, float *I)
 
 	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;
+	I[6] = 0;     I[7] = -s;    I[8] = c;
 
 	return 0;
 }
@@ -163,15 +163,15 @@ int getRotationMatrix(float *accel, float *geo, float *R, float *I)
 
 int remapCoordinateSystem(float *inR, int X, int Y, float *outR)
 {
-	if(inR == NULL || outR == NULL)
+	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 & 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
+		return -1;   /* same axis specified */
 
 	int Z = X ^ Y;
 	int x = (X & 0x3)-1;
@@ -183,17 +183,17 @@ int remapCoordinateSystem(float *inR, int X, int Y, float *outR)
 	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;
+	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];
+	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/geomagnetic_field.c b/src/geomagnetic_field.c
index 65cd52b..90ee40f 100644
--- a/src/geomagnetic_field.c
+++ b/src/geomagnetic_field.c
@@ -50,11 +50,11 @@ const float cd[13][13] = {
 float g_declination = 0;
 float g_inclination = 0;
 
-static void E0000(int IENTRY, int maxdeg, float alt,float glat,float glon, float time, float *dec, float *dip, float *ti, float *gv);
+static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv);
 
 int getDeclination(float *decl)
 {
-	if(decl == NULL)
+	if (decl == NULL)
 		return -1;
 
 	*decl = g_declination;
@@ -64,7 +64,7 @@ int getDeclination(float *decl)
 
 int getInclination(float *incl)
 {
-        if(incl == NULL)
+        if (incl == NULL)
                 return -1;
 
         *incl = g_inclination;
@@ -76,29 +76,25 @@ int setCoordinate(float latitude, float longitude, float altitude, float *declin
 {
 	float dec, dip, ti, gv;
 	float h;
-	float rTd=0.017453292;
+	float rTd = 0.017453292;
 
-	E0000(0,12,0.0,0.0,0.0,0.0,NULL,NULL,NULL,NULL);
-	E0000(1,0,altitude,latitude,longitude,2,&dec,&dip,&ti,&gv);
+	E0000(0, 12, 0.0, 0.0, 0.0, 0.0, NULL, NULL, NULL, NULL);
+	E0000(1, 0, altitude, latitude, longitude, 2, &dec, &dip, &ti, &gv);
 
-	h=ti*(cos((dip*rTd)));
+	h = ti*(cos((dip*rTd)));
 
 	/* deal with geographic and magnetic poles */
 
-	if (h < 100.0) /* at magnetic poles */
-	{
+	if (h < 100.0) {    /* at magnetic poles */
 		dec = 0;
 	}
 
-	if(option == 1)
-	{
-		if(declination != NULL)
+	if (option == 1)	{
+		if (declination != NULL)
 			*declination = dec;
-		if(inclination != NULL)
+		if (inclination != NULL)
 			*inclination = dip;
-	}
-	else if( option == 0)
-	{
+	} else if (option == 0) {
 		g_declination = dec;
 		g_inclination = dip;
 	}
@@ -109,16 +105,16 @@ int setCoordinate(float latitude, float longitude, float altitude, float *declin
 
 static void E0000(int IENTRY, int maxdeg, float alt, float glat, float glon, float time, float *dec, float *dip, float *ti, float *gv)
 {
-	static int maxord,n,m,j,D1,D2,D3,D4;
-	static float tc[13][13],dp[13][13],snorm[169],
-		      sp[13],cp[13],fn[13],fm[13],pp[13],k[13][13],pi,dtr,a,b,re,
-		      a2,b2,c2,a4,b4,c4,flnmj,otime,oalt,
-		      olat,olon,dt,rlon,rlat,srlon,srlat,crlon,crlat,srlat2,
-		      crlat2,q,q1,q2,ct,st,r2,r,d,ca,sa,aor,ar,br,bt,bp,bpp,
-		      par,temp1,temp2,parp,bx,by,bz,bh;
+	static int maxord, n, m, j, D1, D2, D3, D4;
+	static float tc[13][13], dp[13][13], snorm[169],
+		      sp[13], cp[13], fn[13], fm[13], pp[13], k[13][13], pi, dtr, a, b, re,
+		      a2, b2, c2, a4, b4, c4, flnmj, otime, oalt,
+		      olat, olon, dt, rlon, rlat, srlon, srlat, crlon, crlat, srlat2,
+		      crlat2, q, q1, q2, ct, st, r2, r, d, ca, sa, aor, ar, br, bt, bp, bpp,
+		      par, temp1, temp2, parp, bx, by, bz, bh;
 	static float *p = snorm;
 
-	switch(IENTRY){case 0: goto GEOMAG; case 1: goto GEOMG1;}
+	switch (IENTRY) {case 0: goto GEOMAG; case 1: goto GEOMG1; }
 
 GEOMAG:
 	maxord = 12;
@@ -137,15 +133,12 @@ GEOMAG:
 
 	*snorm = 1.0;
 	fm[0] = 0.0;
-	for (n=1; n<=maxord; n++)
-	{
+	for (n = 1; n <= maxord; n++) {
 		*(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n;
 		j = 2;
-		for (m=0,D1=1,D2=(n-m+D1)/D1; D2>0; D2--,m+=D1)
-		{
+		for (m = 0, D1 = 1, D2 = (n-m+D1)/D1; D2 > 0; D2--, m += D1) {
 			k[m][n] = (float)(((n-1)*(n-1))-(m*m))/(float)((2*n-1)*(2*n-3));
-			if (m > 0)
-			{
+			if (m > 0) {
 				flnmj = (float)((n-m+1)*j)/(float)(n+m);
 				*(snorm+n+m*13) = *(snorm+n+(m-1)*13)*sqrt(flnmj);
 				j = 1;
@@ -178,8 +171,7 @@ GEOMG1:
 	sp[1] = srlon;
 	cp[1] = crlon;
 
-	if (alt != oalt || glat != olat)
-	{
+	if (alt != oalt || glat != olat) {
 		q = sqrt(a2-c2*srlat2);
 		q1 = alt*q;
 		q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));
@@ -191,10 +183,8 @@ GEOMG1:
 		ca = (alt+d)/r;
 		sa = c2*crlat*srlat/(r*d);
 	}
-	if (glon != olon)
-	{
-		for (m=2; m<=maxord; m++)
-		{
+	if (glon != olon) {
+		for (m = 2; m <= maxord; m++) {
 			sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];
 			cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];
 		}
@@ -202,27 +192,21 @@ GEOMG1:
 	aor = re/r;
 	ar = aor*aor;
 	br = bt = bp = bpp = 0.0;
-	for (n=1; n<=maxord; n++)
-	{
+	for (n = 1; n <= maxord; n++) {
 		ar = ar*aor;
-		for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3)
-		{
-			if (alt != oalt || glat != olat)
-			{
-				if (n == m)
-				{
+		for (m = 0, D3 = 1, D4 = (n+m+D3)/D3; D4 > 0; D4--, m += D3) {
+			if (alt != oalt || glat != olat) {
+				if (n == m) {
 					*(p+n+m*13) = st**(p+n-1+(m-1)*13);
 					dp[m][n] = st*dp[m-1][n-1]+ct**(p+n-1+(m-1)*13);
 					goto S50;
 				}
-				if (n == 1 && m == 0)
-				{
+				if (n == 1 && m == 0) {
 					*(p+n+m*13) = ct**(p+n-1+m*13);
 					dp[m][n] = ct*dp[m][n-1]-st**(p+n-1+m*13);
 					goto S50;
 				}
-				if (n > 1 && n != m)
-				{
+				if (n > 1 && n != m) {
 					if (m > n-2) *(p+n-2+m*13) = 0.0;
 					if (m > n-2) dp[m][n-2] = 0.0;
 					*(p+n+m*13) = ct**(p+n-1+m*13)-k[m][n]**(p+n-2+m*13);
@@ -230,20 +214,16 @@ GEOMG1:
 				}
 			}
 S50:
-			if (time != otime)
-			{
+			if (time != otime) {
 				tc[m][n] = c[m][n]+dt*cd[m][n];
 				if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];
 			}
 
 			par = ar**(p+n+m*13);
-			if (m == 0)
-			{
+			if (m == 0) {
 				temp1 = tc[m][n]*cp[m];
 				temp2 = tc[m][n]*sp[m];
-			}
-			else
-			{
+			} else {
 				temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];
 				temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];
 			}
@@ -251,8 +231,7 @@ S50:
 			bp += (fm[m]*temp2*par);
 			br += (fn[n]*temp1*par);
 
-			if (st == 0.0 && m == 1)
-			{
+			if (st == 0.0 && m == 1) {
 				if (n == 1) pp[n] = pp[n-1];
 				else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];
 				parp = ar*pp[n];
@@ -268,11 +247,10 @@ S50:
 	bz = bt*sa-br*ca;
 	bh = sqrt((bx*bx)+(by*by));
 	*ti = sqrt((bh*bh)+(bz*bz));
-	*dec = atan2(by,bx)/dtr;
-	*dip = atan2(bz,bh)/dtr;
+	*dec = atan2(by, bx)/dtr;
+	*dip = atan2(bz, bh)/dtr;
 	*gv = -999.0;
-	if (fabs(glat) >= 55.)
-	{
+	if (fabs(glat) >= 55.) {
 		if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;
 		if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);
 		if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;