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");
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;
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();
/* 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, ×tamp)) 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);
}
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, ×tamp)) 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
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, ×tamp)) 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
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, ×tamp)) 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
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, ×tamp)) 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
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, ×tamp)) 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
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, ×tamp)) 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
}
}
+/* 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
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
/* 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));
}
/* 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));
}
/* 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));
}
/* 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));
}
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));
}
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));
}
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));
}
}
/* 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.
}
/* 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.
}
/* 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.
}
/* 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.
}
/* 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.
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
/* 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));
}
/* 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));
}
/* 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));
}
/* 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));
}
}
/* 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));
}
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));
}
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));
}
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));
}
}
/* 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));
}
}
/* 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));
}
}
/* 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));
}
}
/* 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));
}
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
- obj->timestamp = 0;
+ obj->timestamp = ecore_time_get();
break;
case SENSOR_GRAVITY:
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:
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:
obj->data[0] = yaw;
obj->data[1] = pitch;
obj->data[2] = roll;
- obj->timestamp = 0;
+ obj->timestamp = ecore_time_get();
break;
case SENSOR_MAGNETIC:
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
- obj->timestamp = 0;
+ obj->timestamp = ecore_time_get();
break;
case SENSOR_ORIENTATION:
obj->data[0] = azimuth;
obj->data[1] = pitch;
obj->data[2] = roll;
- obj->timestamp = 0;
+ obj->timestamp = ecore_time_get();
break;
case SENSOR_GYROSCOPE:
obj->data[0] = x;
obj->data[1] = y;
obj->data[2] = z;
- obj->timestamp = 0;
+ obj->timestamp = ecore_time_get();
break;
case SENSOR_LIGHT:
/* 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:
/* 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: