diff options
author | stefan <stefan> | 2012-09-28 09:10:47 +0000 |
---|---|---|
committer | stefan <stefan@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-09-28 09:10:47 +0000 |
commit | f29e6a64159faffe05aa8f3e623917f96b082438 (patch) | |
tree | 230f1ec96d27e37f6354a3397ee2500ad7a94b8b | |
parent | f5d306b6e862a9067e65c9df55584ecc9919e607 (diff) | |
download | eeze-f29e6a64159faffe05aa8f3e623917f96b082438.tar.gz eeze-f29e6a64159faffe05aa8f3e623917f96b082438.tar.bz2 eeze-f29e6a64159faffe05aa8f3e623917f96b082438.zip |
eeze/sensor: Fix fake module to set timestamp to microseconds since epoch.
Seconds is not really a suitable resolution for sensor data read outs. This
also aligns it with the tizen module and the public API.
The sleep is no longer needed in the test program either.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eeze@77191 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
-rw-r--r-- | src/bin/eeze_sensor_test.c | 2 | ||||
-rw-r--r-- | src/modules/eeze_sensor_fake.c | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/bin/eeze_sensor_test.c b/src/bin/eeze_sensor_test.c index a996ef3..afc082a 100644 --- a/src/bin/eeze_sensor_test.c +++ b/src/bin/eeze_sensor_test.c @@ -129,8 +129,6 @@ main(void) else printf("Could not find a light sensor!\n"); - sleep(1); - /* Get updated values on a sensor. Read out is synchronous */ eeze_sensor_read(sens); if (!sens) printf("can't find an light sensor!\n"); diff --git a/src/modules/eeze_sensor_fake.c b/src/modules/eeze_sensor_fake.c index 194b5c5..0a45b67 100644 --- a/src/modules/eeze_sensor_fake.c +++ b/src/modules/eeze_sensor_fake.c @@ -3,7 +3,7 @@ #endif #include <stdio.h> -#include <time.h> +#include <sys/time.h> #include <Eina.h> #include <Ecore.h> @@ -38,6 +38,7 @@ 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) @@ -56,7 +57,8 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj) obj->data[0] = 7; obj->data[1] = 23; obj->data[2] = 42; - obj->timestamp = time(NULL); + gettimeofday(&tv, NULL); + obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec); break; case EEZE_SENSOR_TYPE_LIGHT: @@ -65,7 +67,8 @@ fake_read(Eeze_Sensor_Type sensor_type, Eeze_Sensor_Obj *lobj) case EEZE_SENSOR_TYPE_TEMPERATURE: obj->accuracy = 0; obj->data[0] = 7; - obj->timestamp = time(NULL); + gettimeofday(&tv, NULL); + obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec); break; default: @@ -82,6 +85,7 @@ 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) @@ -101,7 +105,8 @@ 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; - obj->timestamp = time(NULL); + gettimeofday(&tv, NULL); + obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec); break; case EEZE_SENSOR_TYPE_LIGHT: @@ -110,7 +115,8 @@ fake_async_read(Eeze_Sensor_Type sensor_type, void *user_data EINA_UNUSED) case EEZE_SENSOR_TYPE_TEMPERATURE: obj->accuracy = 0; obj->data[0] = 7; - obj->timestamp = time(NULL); + gettimeofday(&tv, NULL); + obj->timestamp = ((tv.tv_sec * 1000000) + tv.tv_usec); break; case EEZE_SENSOR_TYPE_MOTION_SNAP: |