eeze/sensor: Switch timestamp to relative values coming.

Switch from absolut microseconds since epoch to a monotonic clock with
realtive values. Switch from unsigned long long to double.

This aligns it with how we present time in efl. ecore_time_get is used
when possible. For the tizen modules we convert the the epoch timestamp
we get into a double. This is still a working monotone clock source.

As this will be released the first time with 1.8 we don't have any API
break here.
This commit is contained in:
Stefan Schmidt 2013-04-16 13:16:55 +01:00
parent 3ccc7e7cf8
commit 763bdd1618
6 changed files with 80 additions and 75 deletions

View File

@ -21,7 +21,7 @@ event_cb(void *data EINA_UNUSED, int ev_type, void *event)
Eeze_Sensor_Obj *sens = NULL;
float x, y, z;
int acc;
unsigned long long timestamp;
double timestamp;
sens = event;
if (!sens) printf("can't find sensor!\n");
@ -31,16 +31,16 @@ event_cb(void *data EINA_UNUSED, int ev_type, void *event)
if (ev_type == EEZE_SENSOR_EVENT_ACCELEROMETER)
{
if (!eeze_sensor_xyz_get(sens, &x, &y, &z)) printf("fail get xyz\n");
printf("Accelerometer callback: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
printf("Accelerometer callback: accuracy %i, x %f, y %f, z %f at time: %f\n", acc, x, y, z, timestamp);
}
else if (ev_type == EEZE_SENSOR_EVENT_FACEDOWN)
printf("Facedown callback at time: %lli\n", timestamp);
printf("Facedown callback at time: %f\n", timestamp);
else if (ev_type == EEZE_SENSOR_EVENT_DOUBLETAP)
printf("Doubletap callback at time: %lli\n", timestamp);
printf("Doubletap callback at time: %f\n", timestamp);
else if (ev_type == EEZE_SENSOR_EVENT_SHAKE)
{
if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
printf("Shake callback: accuracy %i, x %f at time: %lli\n", acc, x, timestamp);
printf("Shake callback: accuracy %i, x %f at time: %f\n", acc, x, timestamp);
}
return ECORE_CALLBACK_PASS_ON;
@ -52,7 +52,7 @@ main(void)
Eeze_Sensor_Obj *sens;
float x, y, z;
int acc;
unsigned long long timestamp;
double timestamp;
/* Init the subsystems we use to make sure they are ready to use. */
ecore_init();
@ -74,7 +74,7 @@ main(void)
/* Here we read the timestamp the data was read out from the physical
* sensor. Can be used to detect how old the readout it.*/
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Magnetic output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
printf("Magnetic output: accuracy %i, x %f, y %f, z %f at time: %f\n", acc, x, y, z, timestamp);
/* Free the sensor when we do not longer use it. */
eeze_sensor_free(sens);
}
@ -87,7 +87,7 @@ main(void)
if (!eeze_sensor_xyz_get(sens, &x, &y, &z)) printf("fail get xyz\n");
if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Acceleromter output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
printf("Acceleromter output: accuracy %i, x %f, y %f, z %f at time: %f\n", acc, x, y, z, timestamp);
eeze_sensor_free(sens);
}
else
@ -99,7 +99,7 @@ main(void)
if (!eeze_sensor_xyz_get(sens, &x, &y, &z)) printf("fail get xyz\n");
if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Orientation output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
printf("Orientation output: accuracy %i, x %f, y %f, z %f at time: %f\n", acc, x, y, z, timestamp);
eeze_sensor_free(sens);
}
else
@ -111,7 +111,7 @@ main(void)
if (!eeze_sensor_xyz_get(sens, &x, &y, &z)) printf("fail get xyz\n");
if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Gyroscope output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
printf("Gyroscope output: accuracy %i, x %f, y %f, z %f at time: %f\n", acc, x, y, z, timestamp);
eeze_sensor_free(sens);
}
else
@ -123,7 +123,7 @@ main(void)
if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Proximity output: accuracy %i, distance %f at time: %lli\n", acc, x, timestamp);
printf("Proximity output: accuracy %i, distance %f at time: %f\n", acc, x, timestamp);
eeze_sensor_free(sens);
}
else
@ -135,7 +135,7 @@ main(void)
if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Light output: accuracy %i, lux %f at time: %lli\n", acc, x, timestamp);
printf("Light output: accuracy %i, lux %f at time: %f\n", acc, x, timestamp);
eeze_sensor_free(sens);
}
else
@ -153,7 +153,7 @@ main(void)
if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
printf("Light output: accuracy %i, lux %f at time: %lli\n", acc, x, timestamp);
printf("Light output: accuracy %i, lux %f at time: %f\n", acc, x, timestamp);
eeze_sensor_free(sens);
}
else

View File

@ -132,7 +132,8 @@ EAPI int EEZE_SENSOR_EVENT_TEMPERATURE;
* Object for a sensor type. Keeps information about the type and holds the
* data for the accessor functions. As this information gets also updated by
* asynchronous reads it might be a good idea to check the timestamp value to
* see when the data has been updated. The timestamp is given in microseconds.
* see when the data has been updated. The timestamp is given as floating point
* value in seconds.
*
* You are not supposed to access the raw data values from here but use the
* getter functions for it. Using the raw values from this struct might break
@ -145,7 +146,7 @@ typedef struct _Eeze_Sensor_Obj
Eeze_Sensor_Type type; /**< Sensor type see #Eeze_Sensor_Type */
int accuracy; /**< Accuracy of the sensor value */
float data[3]; /**< Sensor data depending on the sensor type */
unsigned long long timestamp; /**< Timestamp of data read */
double timestamp; /**< Timestamp of data read */
Eina_Bool continuous_flow; /**< FUTURE USE: Continuous flow of sensor read out */
} Eeze_Sensor_Obj;
@ -255,11 +256,11 @@ EAPI Eina_Bool eeze_sensor_x_get(Eeze_Sensor_Obj *sens, float *x);
*
* Access function to get the timestamp property from the sensor object. It
* allows you to determine if the values have been updated since the last time
* you requested them.
* you requested them. Timestamp is given as a floating point value in seconds.
*
* @since 1.8
*/
EAPI Eina_Bool eeze_sensor_timestamp_get(Eeze_Sensor_Obj *sens, unsigned long long *timestamp);
EAPI Eina_Bool eeze_sensor_timestamp_get(Eeze_Sensor_Obj *sens, double *timestamp);
/**
* @brief Read out sensor data

View File

@ -256,7 +256,7 @@ eeze_sensor_x_get(Eeze_Sensor_Obj *sens, float *x)
}
EAPI Eina_Bool
eeze_sensor_timestamp_get(Eeze_Sensor_Obj *sens, unsigned long long *timestamp)
eeze_sensor_timestamp_get(Eeze_Sensor_Obj *sens, double *timestamp)
{
if (!sens) return EINA_FALSE;

View File

@ -55,7 +55,6 @@ Eina_Bool
fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
{
Eeze_Sensor_Obj *obj = NULL;
struct timeval tv;
obj = eeze_sensor_obj_get(sensor_type);
if (obj == NULL)
@ -78,8 +77,7 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = 7;
obj->data[1] = 23;
obj->data[2] = 42;
gettimeofday(&tv, NULL);
obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec);
obj->timestamp = ecore_time_get();
break;
case EEZE_SENSOR_TYPE_LIGHT:
@ -88,8 +86,7 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
case EEZE_SENSOR_TYPE_TEMPERATURE:
obj->accuracy = -1;
obj->data[0] = 7;
gettimeofday(&tv, NULL);
obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec);
obj->timestamp = ecore_time_get();
break;
default:
@ -108,7 +105,6 @@ Eina_Bool
fake_async_read(Eeze_Sensor_Type sensor_type, void *user_data EINA_UNUSED)
{
Eeze_Sensor_Obj *obj = NULL;
struct timeval tv;
obj = eeze_sensor_obj_get(sensor_type);
if (obj == NULL)
@ -122,8 +118,7 @@ fake_async_read(Eeze_Sensor_Type sensor_type, void *user_data EINA_UNUSED)
obj->data[0] = 7;
obj->data[1] = 23;
obj->data[2] = 42;
gettimeofday(&tv, NULL);
obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec);
obj->timestamp = ecore_time_get();
switch (sensor_type)
{

View File

@ -165,6 +165,15 @@ tizen_to_eeze(sesnor_type_e type)
}
}
/* We receive the timestamp in nanoseconds from the Tizen system lib. Convert
* it to seconds as floating point value which is used in our public API.
*/
double
clock_convert(unsigned long long timestamp)
{
return ((double)timestamp) / 1000000000.0;
}
/* All following callback function work with the same scheme.
* They are callbacks coming in from the tizen system sensor library. With the
* data we receive we update the matching sensor object to always have the
@ -189,7 +198,7 @@ accelerometer_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy,
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_ACCELEROMETER, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ACCELEROMETER));
}
@ -209,7 +218,7 @@ gravity_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_GRAVITY, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GRAVITY));
}
@ -229,7 +238,7 @@ linear_acceleration_cb(unsigned long long timestamp, sensor_data_accuracy_e accu
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_LINEAR_ACCELERATION, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LINEAR_ACCELERATION));
}
@ -250,7 +259,7 @@ device_orientation_cb(unsigned long long timestamp, sensor_data_accuracy_e accur
obj->data[0] = yaw;
obj->data[1] = pitch;
obj->data[2] = roll;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_DEVICE_ORIENTATION, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_DEVICE_ORIENTATION));
}
@ -270,7 +279,7 @@ magnetic_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, float
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_MAGNETIC, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MAGNETIC));
}
@ -290,7 +299,7 @@ orientation_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, fl
obj->data[0] = azimuth;
obj->data[1] = pitch;
obj->data[2] = roll;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_ORIENTATION, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ORIENTATION));
}
@ -310,7 +319,7 @@ gyroscope_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, floa
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_GYROSCOPE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GYROSCOPE));
}
@ -329,7 +338,7 @@ light_cb(unsigned long long timestamp, float lux, void *user_data)
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = lux;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_LIGHT, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LIGHT));
}
@ -348,7 +357,7 @@ proximity_cb(unsigned long long timestamp, float distance, void *user_data)
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = distance;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_PROXIMITY, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_PROXIMITY));
}
@ -367,7 +376,7 @@ snap_cb(unsigned long long timestamp, sensor_motion_snap_e snap, void *user_data
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = snap;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_SNAP, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SNAP));
}
@ -386,7 +395,7 @@ shake_cb(unsigned long long timestamp, sensor_motion_shake_e shake, void *user_d
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = shake;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_SHAKE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SHAKE));
}
@ -406,7 +415,7 @@ panning_cb(unsigned long long timestamp, int x, int y, void *user_data)
obj->accuracy = -1;
obj->data[0] = x;
obj->data[1] = y;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_PANNING, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING));
}
@ -426,7 +435,7 @@ panning_browse_cb(unsigned long long timestamp, int x, int y, void *user_data)
obj->accuracy = -1;
obj->data[0] = x;
obj->data[1] = y;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_PANNING_BROWSE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING_BROWSE));
}
@ -446,7 +455,7 @@ tilt_cb(unsigned long long timestamp, int x, int y, void *user_data)
obj->accuracy = -1;
obj->data[0] = x;
obj->data[1] = y;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_TILT, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_TILT));
}
@ -464,7 +473,7 @@ facedown_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_FACEDOWN, obj, NULL, NULL);
/* We are not stopping the sensor here because we want to keep it as a motion
* event coming in at any time.
@ -484,7 +493,7 @@ directcall_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_DIRECT_CALL, obj, NULL, NULL);
/* We are not stopping the sensor here because we want to keep it as a motion
* event coming in at any time.
@ -504,7 +513,7 @@ smart_alert_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_SMART_ALERT, obj, NULL, NULL);
/* We are not stopping the sensor here because we want to keep it as a motion
* event coming in at any time.
@ -524,7 +533,7 @@ no_move_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_NO_MOVE, obj, NULL, NULL);
/* We are not stopping the sensor here because we want to keep it as a motion
* event coming in at any time.
@ -544,7 +553,7 @@ doubletap_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_DOUBLETAP, obj, NULL, NULL);
/* We are not stopping the sensor here because we want to keep it as a motion
* event coming in at any time.
@ -568,7 +577,7 @@ accelerometer_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accur
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_ACCELEROMETER, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ACCELEROMETER));
}
@ -590,7 +599,7 @@ gravity_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy, f
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_GRAVITY, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GRAVITY));
}
@ -612,7 +621,7 @@ linear_acceleration_read_cb(unsigned long long timestamp, sensor_data_accuracy_e
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_LINEAR_ACCELERATION, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LINEAR_ACCELERATION));
}
@ -635,7 +644,7 @@ device_orientation_read_cb(unsigned long long timestamp, sensor_data_accuracy_e
obj->data[0] = yaw;
obj->data[1] = pitch;
obj->data[2] = roll;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_DEVICE_ORIENTATION, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_DEVICE_ORIENTATION));
}
@ -657,7 +666,7 @@ magnetic_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy,
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_MAGNETIC, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MAGNETIC));
}
@ -679,7 +688,7 @@ orientation_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accurac
obj->data[0] = azimuth;
obj->data[1] = pitch;
obj->data[2] = roll;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_ORIENTATION, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_ORIENTATION));
}
@ -701,7 +710,7 @@ gyroscope_read_cb(unsigned long long timestamp, sensor_data_accuracy_e accuracy,
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_GYROSCOPE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_GYROSCOPE));
}
@ -722,7 +731,7 @@ light_read_cb(unsigned long long timestamp, float lux, void *user_data)
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = lux;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_LIGHT, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_LIGHT));
}
@ -743,7 +752,7 @@ proximity_read_cb(unsigned long long timestamp, float distance, void *user_data)
/* We have to set this ourselves because we don't get it for this type */
bj->accuracy = -1;
obj->data[0] = distance;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_PROXIMITY, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_PROXIMITY));
}
@ -764,7 +773,7 @@ snap_read_cb(unsigned long long timestamp, sensor_motion_snap_e snap, void *user
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = snap;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_SNAP, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SNAP));
}
@ -785,7 +794,7 @@ shake_read_cb(unsigned long long timestamp, sensor_motion_shake_e shake, void *u
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->data[0] = shake;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_SHAKE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SHAKE));
}
@ -805,7 +814,7 @@ doubletap_read_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_DOUBLETAP, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_DOUBLETAP));
}
@ -827,7 +836,7 @@ panning_read_cb(unsigned long long timestamp, int x, int y, void *user_data)
obj->accuracy = -1;
obj->data[0] = x;
obj->data[1] = y;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_PANNING, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING));
}
@ -849,7 +858,7 @@ panning_browse_read_cb(unsigned long long timestamp, int x, int y, void *user_da
obj->accuracy = -1;
obj->data[0] = x;
obj->data[1] = y;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_PANNING_BROWSE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_PANNING_BROWSE));
}
@ -871,7 +880,7 @@ tilt_read_cb(unsigned long long timestamp, int x, int y, void *user_data)
obj->accuracy = -1;
obj->data[0] = x;
obj->data[1] = y;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_TILT, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_TILT));
}
@ -891,7 +900,7 @@ facedown_read_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_FACEDOWN, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_FACEDOWN));
}
@ -911,7 +920,7 @@ directcall_read_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_DIRECT_CALL, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_DIRECT_CALL));
}
@ -931,7 +940,7 @@ smart_alert_read_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_SMART_ALERT, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_SMART_ALERT));
}
@ -951,7 +960,7 @@ no_move_read_cb(unsigned long long timestamp, void *user_data)
}
/* We have to set this ourselves because we don't get it for this type */
obj->accuracy = -1;
obj->timestamp = timestamp;
obj->timestamp = clock_convert(timestamp);
ecore_event_add(EEZE_SENSOR_EVENT_NO_MOVE, obj, NULL, NULL);
sensor_stop(sensor_handle, eeze_to_tizen(EEZE_SENSOR_TYPE_MOTION_NO_MOVE));
}
@ -999,7 +1008,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_GRAVITY:
@ -1008,7 +1017,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_LINEAR_ACCELERATION:
@ -1017,7 +1026,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_DEVICE_ORIENTATION:
@ -1026,7 +1035,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = yaw;
obj->data[1] = pitch;
obj->data[2] = roll;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_MAGNETIC:
@ -1035,7 +1044,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_ORIENTATION:
@ -1044,7 +1053,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = azimuth;
obj->data[1] = pitch;
obj->data[2] = roll;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_GYROSCOPE:
@ -1053,7 +1062,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_LIGHT:
@ -1061,7 +1070,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
/* As we do not get any accuracy value from the system we go with -1 */
obj->accuracy = -1;
obj->data[0] = lux;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
case SENSOR_PROXIMITY:
@ -1069,7 +1078,7 @@ eeze_sensor_tizen_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj)
/* As we do not get any accuracy value from the system we go with -1 */
obj->accuracy = -1;
obj->data[0] = distance;
obj->timestamp = 0;
obj->timestamp = ecore_time_get();
break;
default:

View File

@ -363,7 +363,7 @@ START_TEST(eeze_test_sensor_read)
int ret = 0;
float x, y, z;
int acc;
unsigned long long timestamp;
double timestamp;
Eina_Bool rc = EINA_FALSE;
ecore_init();
@ -499,7 +499,7 @@ event_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
{
Eeze_Sensor_Obj *sens = NULL;
int acc;
unsigned long long timestamp;
double timestamp;
Eina_Bool rc = EINA_FALSE;
sens = event;