+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
-#ifndef __TIZEN_SYSTEM_SENSOR_PRIVATE_H__
-#define __TIZEN_SYSTEM_SENSOR_PRIVATE_H__
+#ifndef __SENSOR_PRIVATE_H__
+#define __SENSOR_PRIVATE_H__
#ifdef __cplusplus
extern "C"
}
#endif
-#endif // __TIZEN_SYSTEM_SENSOR_PRIVATE_H__
+#endif // __SENSOR_PRIVATE_H__
-#ifndef __TIZEN_SYSTEM_SENSOR_H__
-#define __TIZEN_SYSTEM_SENSOR_H__
+#ifndef __SENSOR_H__
+#define __SENSOR_H__
#include <tizen_error.h>
#include <tizen_type.h>
* @brief Called when a gyroscope event occurs.
*
* @remark
- * All values are in radians/second and measure the rate of rotation around the X, Y and Z axis. \n
- * The coordinate system is the same as is used for the acceleration sensor. Rotation is positive \n
- * in the counter-clockwise direction. That is, an observer looking from some positive location \n
- * on the @a x, @a y, or @a z axis at a device positioned on the origin would report positive rotation if \n
- * the device appeared to be rotating counter clockwise. Note that this is the standard mathematical \n
- * definition of positive rotation and does not agree with the definition of roll given earlier.
+ * 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] 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
* @brief Called when a light event occurs.
*
* @remark
- * All values are neither SI lux units (lx), nor adc.\n
- * Values returned by sensor may vary depending on a hardware. In the case of some\n
- * HW, level 1 can mean 1 ~ 100 lux, while in some other case, level 1 can mean 1~50 lux.\n
- * You should use light level between min and max values obtained \n
- * with #sensor_get_spec(). In most cases min is 1 and max is 10.
+ * 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] level Actual light level
- * @param[in] level Ambient light level between min and max values obtained with #sensor_get_spec().\n
+ * @param[in] lux The ambient light level in SI lux units \n
+ * @a lux is between min and max values obtained with #sensor_get_spec().\n
* @param[in] user_data The user data passed from the callback registration function
* @pre sensor_start() will invoke this callback if you register this callback using sensor_light_set_cb().
* @see sensor_light_set_cb()
* @see sensor_light_unset_cb()
*/
typedef void (*sensor_light_event_cb)(
- sensor_data_accuracy_e accuracy, int level, void *user_data);
+ sensor_data_accuracy_e accuracy, float lux, void *user_data);
/**
* @}
*/
/**
* @brief Called when a proximity event occurs.
*
- * @param[out] is_near @c true if an object is close to the phone, otherwise @c false
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] distance The distance measured in centemeters
+ * @param[in] user_data The user data passed from the callback registration function
* @pre sensor_start() will invoke this callback if you register this callback using sensor_proximity_set_cb().
* @see sensor_proximity_set_cb()
* @see sensor_proximity_unset_cb()
*/
-typedef void (*sensor_proximity_event_cb)(bool is_near, void *user_data);
+typedef void (*sensor_proximity_event_cb)(sensor_data_accuracy_e accuracy, float distance, void *user_data);
/**
* @}
*/
* @brief Gets sensor data from the light sensor.
*
* @remark
- * All values are neither SI lux units (lx), nor adc.\n
- * Values returned by sensor may vary depending on a hardware. In some devices,
- * HW level 1 can mean 1 ~ 100 lux, while in others, HW level 1 can mean 1 ~ 50 lux.\n
- * You should use light level between min and max values obtained \n
- * with #sensor_get_spec(). In most cases min is 1 and max is 10.
+ * You should use lux between min and max values obtained \n
+ * with #sensor_get_spec().
*
* @param[in] sensor The sensor handle
* @param[out] accuracy The accuracy of this data
- * @param[out] level The ambient light level in SI lux units \n
- * @a level is between min and max values obtained with #sensor_get_spec().\n
+ * @param[out] lux The ambient light level in SI lux units \n
+ * @a lux is between min and max values obtained with #sensor_get_spec().\n
*
* @return 0 on success, otherwise a negative error value
* @retval #SENSOR_ERROR_NONE Successful
* @see #sensor_data_accuracy_e
* @see sensor_start()
*/
-int sensor_light_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, int *level);
+int sensor_light_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *lux);
/**
* @}
* @brief Registers a callback function to be invoked when a proximity event occurs.
*
* @param[in] sensor The sensor handle
+ * @param[in] interval_ms The interval sensor events are delivered in (in milliseconds) \n
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
*
* @see sensor_proximity_event_cb()
* @see sensor_proximity_unset_cb()
*/
-int sensor_proximity_set_cb(sensor_h sensor, sensor_proximity_event_cb callback, void *user_data);
+int sensor_proximity_set_cb(sensor_h sensor, int interval_ms, sensor_proximity_event_cb callback, void *user_data);
/**
* @brief Unregister the proximity callback function.
int sensor_proximity_unset_cb(sensor_h sensor);
/**
+ * @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
+ * @retval #SENSOR_ERROR_NONE Successful
+ * @retval #SENSOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SENSOR_ERROR_IO_ERROR I/O error
+ *
+ * @pre In order to read sensor data, an application should call sensor_start().
+ * @see sensor_start()
+ */
+int sensor_proximity_read_data(sensor_h sensor, sensor_data_accuracy_e *accuracy, float *distance);
+/**
* @}
*
* @}
int _DTYPE[] = {
ACCELEROMETER_BASE_DATA_SET,
- GEOMAGNETIC_RAW_DATA_SET, // really magnetic?
- GEOMAGNETIC_BASE_DATA_SET, // really orientation?
+ GEOMAGNETIC_RAW_DATA_SET,
+ GEOMAGNETIC_BASE_DATA_SET,
GYRO_BASE_DATA_SET,
- LIGHT_BASE_DATA_SET,
- PROXIMITY_BASE_DATA_SET,
+ LIGHT_LUX_DATA_SET,
+ PROXIMITY_DISTANCE_DATA_SET,
+ MOTION_SENSOR,
+ MOTION_SENSOR,
+ MOTION_SENSOR,
+ MOTION_SENSOR,
+ MOTION_SENSOR,
};
int _EVENT[] = {
ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME,
- GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, // really magnetic?
- GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME, // really orientation?
+ GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME,
+ GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME,
GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME,
- LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME, // rate = 500ms
- PROXIMITY_EVENT_CHANGE_STATE,
+ LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME,
+ PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME,
MOTION_ENGINE_EVENT_SNAP,
MOTION_ENGINE_EVENT_SHAKE,
MOTION_ENGINE_EVENT_DOUBLETAP,
sensor_panning_data_t *panning_data = NULL;
int motion = 0;
int nid = 0;
- bool proximity = 0;
+// bool proximity = 0;
sensor_h sensor = (sensor_h)udata;
case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
nid = SENSOR_GYROSCOPE;
break;
- case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME :
+ case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
nid = SENSOR_LIGHT;
break;
- case PROXIMITY_EVENT_CHANGE_STATE :
+ case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
nid = SENSOR_PROXIMITY;
break;
}
case GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME :
case GEOMAGNETIC_EVENT_ATTITUDE_DATA_REPORT_ON_TIME :
case GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME :
- case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME :
+ case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME :
+ case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
data = (sensor_data_t*)(event->event_data);
data_num = (event->event_data_size)/sizeof(sensor_data_t);
break;
+ /*
case PROXIMITY_EVENT_CHANGE_STATE :
proximity = *(int*)(event->event_data) == PROXIMITY_STATE_FAR ? 0 : 1;
break;
+ */
default:
DEBUG_PRINTF("unknown typed sensor happen!! event=%d\n", event_type);
return;
sensor->cb_user_data[nid]);
}
break;
- case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME :
+ 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),
- (int)data[i].values[0],
+ data[i].values[0],
sensor->cb_user_data[nid]);
}
break;
- case PROXIMITY_EVENT_CHANGE_STATE :
+ case PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME :
+ for(i=0; i<data_num; i++){
((sensor_proximity_event_cb)sensor->cb_func[nid])
- (proximity, sensor->cb_user_data[nid]);
+ (_ACCU(data[i].data_accuracy),
+ data[i].values[0],
+ sensor->cb_user_data[nid]);
+ }
break;
}
}
int sensor_get_spec(sensor_type_e type, float* max, float* min, float* resolution)
{
- sensor_properties_t property;
+ sensor_data_properties_t properties;
DEBUG_PRINT("sensor_get_spec");
RETURN_IF_NOT_TYPE(type);
- if(sf_get_properties(_TYPE[type], &property) < 0)
+ if(sf_get_data_properties(_DTYPE[type], &properties) < 0)
RETURN_ERROR(SENSOR_ERROR_NOT_SUPPORTED);
- *max = property.sensor_max_range;
- *min = property.sensor_min_range;
- *resolution = property.sensor_resolution;
+ *max = properties.sensor_max_range;
+ *min = properties.sensor_min_range;
+ *resolution = properties.sensor_resolution;
DEBUG_PRINTF("success get %s's format max=%f, min=%f, res=%f\n", TYPE_NAME(type), *max, *min, *resolution);
return _sensor_unset_data_cb(handle, SENSOR_LIGHT);
}
-int sensor_proximity_set_cb (sensor_h handle, sensor_proximity_event_cb callback, void *user_data)
+int sensor_proximity_set_cb (sensor_h handle, int interval_ms, sensor_proximity_event_cb callback, void *user_data)
{
- return _sensor_set_data_cb(handle, SENSOR_PROXIMITY, 0, (void*) callback, user_data);
+ return _sensor_set_data_cb(handle, SENSOR_PROXIMITY, interval_ms, (void*) callback, user_data);
}
int sensor_proximity_unset_cb (sensor_h handle)
return SENSOR_ERROR_NONE;
}
-int sensor_light_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, int* level)
+int sensor_light_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, float* lux)
{
float values[1] = {0};
int err = _sensor_read_data(handle, SENSOR_LIGHT, accuracy, values, 1);
if(err < 0) return err;
- if(level == NULL)
+ if(lux == NULL)
RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
- *level = (int)values[0];
+ *lux = values[0];
return SENSOR_ERROR_NONE;
}
-int sensor_proximity_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, bool* is_near)
+int sensor_proximity_read_data (sensor_h handle, sensor_data_accuracy_e* accuracy, float* distance)
{
float values[1] = {0};
int err = _sensor_read_data(handle, SENSOR_PROXIMITY, accuracy, values, 1);
if(err < 0) return err;
- if(is_near == NULL)
+ if(distance == NULL)
RETURN_ERROR(SENSOR_ERROR_INVALID_PARAMETER);
- *is_near = (bool)values[0];
+ *distance = values[0];
return SENSOR_ERROR_NONE;
}