summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@datenfreihafen.org>2012-12-03 14:45:19 +0000
committerStefan Schmidt <stefan@datenfreihafen.org>2012-12-03 14:45:19 +0000
commita94b021f17042127516ecadb7d3493ab9fd76d84 (patch)
treefcdb0e182f127a8db225ca5d0822a789c4c4752e /legacy
parenta3269e66fe4a7efaf212013d188584d3011ed3af (diff)
eeze: Also give the eeze_sensor_test example a bit more comments.
SVN revision: 80073
Diffstat (limited to 'legacy')
-rw-r--r--legacy/eeze/src/bin/eeze_sensor_test.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/legacy/eeze/src/bin/eeze_sensor_test.c b/legacy/eeze/src/bin/eeze_sensor_test.c
index afc082a390..d158ee1de6 100644
--- a/legacy/eeze/src/bin/eeze_sensor_test.c
+++ b/legacy/eeze/src/bin/eeze_sensor_test.c
@@ -54,17 +54,28 @@ main(void)
54 int acc; 54 int acc;
55 unsigned long long timestamp; 55 unsigned long long timestamp;
56 56
57 /* Init the subsystems we use to make sure they are ready to use. */
57 ecore_init(); 58 ecore_init();
58 eeze_init(); 59 eeze_init();
59 60
60 printf("=== Test sync reads: ===\n"); 61 printf("=== Test sync reads: ===\n");
62 /* Create a new sensor object from the type MAGNETIC. We will operate on this
63 * object to get data out of the sensor */
61 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC); 64 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
62 if (sens) 65 if (sens)
63 { 66 {
67 /* Request the actual sensor data from the object. A magnetic sensor
68 * has three data points so we have to use the xyz function. The data
69 * could be cached from the last read so better also get the timestamp
70 * when the data got read form the physical sensor. */
64 if (!eeze_sensor_xyz_get(sens, &x, &y, &z)) printf("fail get xyz\n"); 71 if (!eeze_sensor_xyz_get(sens, &x, &y, &z)) printf("fail get xyz\n");
72 /* Get the accurancy of the reading. Not all sensors support this. */
65 if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n"); 73 if (!eeze_sensor_accuracy_get(sens, &acc)) printf("fail get accuracy\n");
74 /* Here we read the timestamp the data was read out from the physical
75 * sensor. Can be used to detect how old the readout it.*/
66 if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n"); 76 if (!eeze_sensor_timestamp_get(sens, &timestamp)) printf("fail get timestamp\n");
67 printf("Magnetic output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp); 77 printf("Magnetic output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
78 /* Free the sensor when we do not longer use it. */
68 eeze_sensor_free(sens); 79 eeze_sensor_free(sens);
69 } 80 }
70 else 81 else
@@ -129,7 +140,10 @@ main(void)
129 else 140 else
130 printf("Could not find a light sensor!\n"); 141 printf("Could not find a light sensor!\n");
131 142
132 /* Get updated values on a sensor. Read out is synchronous */ 143 /* Get updated values on a sensor. This readout is synchronous. This way we
144 * can force a read out of the physical sensor instead of using the cached
145 * values. Depending on the hardware this can take a long time. If you don't have special
146 * requirements the cached values should be used. */
133 eeze_sensor_read(sens); 147 eeze_sensor_read(sens);
134 if (!sens) printf("can't find an light sensor!\n"); 148 if (!sens) printf("can't find an light sensor!\n");
135 if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n"); 149 if (!eeze_sensor_x_get(sens, &x)) printf("fail get x\n");
@@ -139,8 +153,8 @@ main(void)
139 eeze_sensor_free(sens); 153 eeze_sensor_free(sens);
140 154
141 printf("=== Test async reads / events: ===\n"); 155 printf("=== Test async reads / events: ===\n");
142 /* Async read request for sensors. You have to register an event handler for it first and then 156 /* Async read request for sensors. You have to register an event handler for
143 * request the read out */ 157 * it first and then request the readout */
144 ecore_event_handler_add(EEZE_SENSOR_EVENT_ACCELEROMETER, event_cb, NULL); 158 ecore_event_handler_add(EEZE_SENSOR_EVENT_ACCELEROMETER, event_cb, NULL);
145 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER); 159 sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
146 eeze_sensor_async_read(sens, NULL); 160 eeze_sensor_async_read(sens, NULL);