* - 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
*
*
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
*
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
*
*/
* - 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
*
*
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
*
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
*
*/
* - 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
*
*
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
*
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"><b>Feature Element</b>.</a>
*
*
*/
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-sensor")
+
+PROJECT(${fw_name})
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED "capi-base-common")
+SET(VERSION ${FULLVER})
+
+CONFIGURE_FILE(
+ ../${fw_name}.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+ @ONLY
+)
+
+INSTALL(DIRECTORY include/ DESTINATION include/sensor FILES_MATCHING PATTERN "*.h")
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SENSOR_H__
+#define __SENSOR_H__
+
+#pragma GCC diagnostic warning "-Wunused-value"
+#pragma GCC diagnostic warning "-Wunused-variable"
+#pragma GCC diagnostic warning "-Wunused-but-set-variable"
+#pragma GCC diagnostic warning "-Wmaybe-uninitialized"
+
+#include <tizen.h>
+
+#define MAX_VALUE_SIZE 16
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef void* sensor_h;
+
+typedef struct sensor_listener_s *sensor_listener_h;
+
+typedef struct
+{
+ int accuracy; /**< Accuracy */
+ unsigned long long timestamp; /**< Timestamp */
+ int value_count; /**< Count of values */
+ float values[MAX_VALUE_SIZE]; /**< Sensor values */
+} sensor_event_s;
+
+typedef enum
+{
+ SENSOR_DATA_ACCURACY_UNDEFINED = -1, /**< Undefined accuracy */
+ SENSOR_DATA_ACCURACY_BAD = 0, /**< Bad accuracy */
+ SENSOR_DATA_ACCURACY_NORMAL = 1, /**< Normal accuracy */
+ SENSOR_DATA_ACCURACY_GOOD = 2, /**< Good accuracy */
+ SENSOR_DATA_ACCURACY_VERYGOOD = 3 /**< Very good accuracy */
+} sensor_data_accuracy_e;
+
+typedef enum
+{
+ SENSOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ SENSOR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ SENSOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ SENSOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Unsupported sensor in the current device */
+ SENSOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ SENSOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ SENSOR_ERROR_NOT_NEED_CALIBRATION = TIZEN_ERROR_SENSOR | 0x03, /**< Sensor doesn't need calibration */
+ SENSOR_ERROR_OPERATION_FAILED = TIZEN_ERROR_SENSOR | 0x06, /**< Operation failed */
+} sensor_error_e;
+
+typedef enum
+{
+ SENSOR_PROXIMITY_NEAR = 0, /**< The object is near */
+ SENSOR_PROXIMITY_FAR = 5, /**< The object is far */
+} sensor_proximity_e;
+
+typedef enum
+{
+ SENSOR_ALL = -1, /**< All sensors */
+ SENSOR_ACCELEROMETER, /**< Accelerometer */
+ SENSOR_GRAVITY, /**< Gravity sensor */
+ SENSOR_LINEAR_ACCELERATION, /**< Linear acceleration sensor */
+ SENSOR_MAGNETIC, /**< Magnetic sensor */
+ SENSOR_ROTATION_VECTOR, /**< Rotation Vector sensor */
+ SENSOR_ORIENTATION, /**< Orientation sensor */
+ SENSOR_GYROSCOPE, /**< Gyroscope sensor */
+ SENSOR_LIGHT, /**< Light sensor */
+ SENSOR_PROXIMITY, /**< Proximity sensor */
+ SENSOR_PRESSURE, /**< Pressure sensor */
+ SENSOR_ULTRAVIOLET, /**< Ultraviolet sensor */
+ SENSOR_TEMPERATURE, /**< Temperature sensor */
+ SENSOR_HUMIDITY, /**< Humidity 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;
+
+#ifndef __SENSOR_COMMON_H__
+typedef enum
+{
+ SENSOR_OPTION_DEFAULT, /**< Does not receive data when the LCD is off and in the power save mode */
+ SENSOR_OPTION_ON_IN_SCREEN_OFF, /**< Receives data when the LCD is off */
+ SENSOR_OPTION_ON_IN_POWERSAVE_MODE, /**< Receives data in the power save mode */
+ SENSOR_OPTION_ALWAYS_ON, /**< Receives data when the LCD is off and in the power save mode */
+} sensor_option_e;
+#endif
+
+#define sensor_is_supported(type, supported) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_default_sensor(type, sensor) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_sensor_list(type, list, sensor_count) SENSOR_ERROR_NOT_SUPPORTED
+
+typedef void (*sensor_event_cb)(sensor_h sensor, sensor_event_s *event, void *data);
+
+#define sensor_create_listener(sensor, listener) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_destroy_listener(listener) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_start(listener) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_stop(listener) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_set_event_cb(listener, interval_ms, callback, data) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_unset_event_cb(listener) SENSOR_ERROR_NOT_SUPPORTED
+
+typedef void (*sensor_accuracy_changed_cb)(sensor_h sensor, unsigned long long timestamp, sensor_data_accuracy_e accuracy, void *data);
+
+#define sensor_listener_set_accuracy_cb(listener, callback, data) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_unset_accuracy_cb(listener) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_read_data(listener, event) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_set_interval(listener, interval_ms) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_set_max_batch_latency(listener, max_batch_latency) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_listener_set_option(listener, option) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_name(sensor, name) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_vendor(sensor, vendor) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_type(sensor, type) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_min_range(sensor, min_range) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_max_range(sensor, max_range) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_resolution(sensor, resolution) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_min_interval(sensor, min_interval) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_fifo_count(sensor, fifo_count) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_get_max_batch_count(sensor, max_batch_count) SENSOR_ERROR_NOT_SUPPORTED
+
+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;
+
+#define sensor_util_get_rotation_matrix(Gx, Gy, Gz, Mx, My, Mz, R, I) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_util_get_rotation_matrix_from_vector(Vx, Vy, Vz, R) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_util_remap_coordinate_system(inR, x, y, outR) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_util_get_inclination(I, inclination) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_util_get_orientation(R, values) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_util_get_angle_change(R, prevR, angleChange) SENSOR_ERROR_NOT_SUPPORTED
+#define sensor_util_get_declination(latitude, longitude, altitude, declination) SENSOR_ERROR_NOT_SUPPORTED
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SENSOR_H__ */
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 Gets sensor data.
+ * @details This function may fail (return #SENSOR_ERROR_OPERATION_FAILED) if it is called before the sensor is ready.
+ * In case of interval-driven sensors,
+ * it is recommended to call the function after at least one sensor event is delivered.
+ * Otherwise, applications can retry to call this function to be sure that the sensor is ready.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
* @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #SENSOR_ERROR_NOT_SUPPORTED The sensor type is not supported in the current device
* @retval #SENSOR_ERROR_IO_ERROR I/O error
+ * @retval #SENSOR_ERROR_OPERATION_FAILED Operation failed
*
* @pre In order to read sensor data, an application should call sensor_listener_start().
*/
/**
* @brief Changes the interval at sensor measurements.
+ * @details The specified interval is only a suggested interval between sensor measurements.
+ * You will get at least one sensor measurement within the interval you specify,
+ * but the actual interval between sensor measurements can be affected by other applications and the system.
+ * To reduce the system overhead, it is recommended to set the longest interval that you can,
+ * because the system usually chooses the shortest interval among all intervals specified.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
/**
* @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.
+ * @details If it is default, sensor data cannot be received when the LCD is off and in the power save mode.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*
* @param[in] listener The listener handle
Name: capi-system-sensor
Summary: A Sensor library in TIZEN C API
-Version: 0.1.18
+Version: 0.2.0
Release: 10
Group: TO_BE/FILLED_IN
License: Apache-2.0 and PD
Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
+BuildRequires: pkgconfig(capi-base-common)
+
+%define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}}
+
+%if "%{?BUILD_PROFILE}" != "tv"
+##### Begin: Normal build spec #####
+
+
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(sensor)
-BuildRequires: pkgconfig(capi-base-common)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-system-sensor.so
+
+##### End: Normal build spec #####
+%else
+##### Begin: Dummy build spec #####
+
+
+%description
+Native Sensor API (dummy)
+
+%package devel
+Summary: A Sensor library in TIZEN C API (Development)
+Group: System/API
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Native Sensor API (dummy)
+
+%prep
+%setup -q
+
+%build
+cmake ./dummy -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}/%{_datadir}/license
+cp LICENSE %{buildroot}/%{_datadir}/license/%{name}
+
+%files
+%manifest capi-system-sensor.manifest
+%{_datadir}/license/%{name}
+
+%files devel
+%manifest capi-system-sensor.manifest
+%{_includedir}/sensor/*.h
+%{_libdir}/pkgconfig/*.pc
+
+
+##### End: Dummy build spec #####
+%endif
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];
}
int quatToMatrix(float *quat, float *R)
{
- if(quat == NULL || R == NULL)
+ if (quat == NULL || R == NULL)
return -1;
float q0 = quat[0];
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]);
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];
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;
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;
}
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;
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;
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;
int getInclination(float *incl)
{
- if(incl == NULL)
+ if (incl == NULL)
return -1;
*incl = g_inclination;
{
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;
}
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;
*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;
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));
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];
}
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);
}
}
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];
}
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];
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;
BIO_LED_GREEN_SENSOR,
BIO_LED_IR_SENSOR,
BIO_LED_RED_SENSOR,
+ GYROSCOPE_UNCAL_SENSOR,
+ GEOMAGNETIC_UNCAL_SENSOR,
+ GAMING_RV_SENSOR,
+ GEOMAGNETIC_RV_SENSOR,
};
static int sensor_connect (sensor_h sensor, sensor_listener_h listener)
if (listener->magic != SENSOR_LISTENER_MAGIC)
return SENSOR_ERROR_INVALID_PARAMETER;
- if (!sensord_change_event_max_batch_latency(listener->id, max_batch_latency))
+#ifdef BATCH_SUPPORT
+ int type;
+ unsigned int event_id;
+
+ type = (int)listener->type;
+ event_id = type << SENSOR_SHIFT_TYPE | 0x1;
+
+ if (!sensord_change_event_max_batch_latency(listener->id, event_id, max_batch_latency))
return SENSOR_ERROR_NOT_SUPPORTED;
_D("success sensor_set_max_batch_latency");
return SENSOR_ERROR_NONE;
+#else
+ return SENSOR_ERROR_NOT_SUPPORTED;
+#endif /* BATCH_SUPPORT */
}
int sensor_listener_set_option(sensor_listener_h listener, sensor_option_e option)