forked from enlightenment/efl
eeze/sensor: Be more failure tolerant in example.
If the sensor does not exist we should not ask for its properties. SVN revision: 76918
This commit is contained in:
parent
63c3e6cc3c
commit
33e20cf2a0
|
@ -59,51 +59,75 @@ main(void)
|
|||
|
||||
printf("=== Test sync reads: ===\n");
|
||||
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_MAGNETIC);
|
||||
if (!sens) printf("can't find an magnetic sensor!\n");
|
||||
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("Magnetic output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
|
||||
eeze_sensor_free(sens);
|
||||
if (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("Magnetic output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
|
||||
eeze_sensor_free(sens);
|
||||
}
|
||||
else
|
||||
printf("Could not find a magnetic sensor!\n");
|
||||
|
||||
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ACCELEROMETER);
|
||||
if (!sens) printf("can't find an accelerometer sensor!\n");
|
||||
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("Accel output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
|
||||
eeze_sensor_free(sens);
|
||||
if (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);
|
||||
eeze_sensor_free(sens);
|
||||
}
|
||||
else
|
||||
printf("Could not find an accelerometer sensor!\n");
|
||||
|
||||
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_ORIENTATION);
|
||||
if (!sens) printf("can't find an orientation sensor!\n");
|
||||
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);
|
||||
eeze_sensor_free(sens);
|
||||
if (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("Orientation output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
|
||||
eeze_sensor_free(sens);
|
||||
}
|
||||
else
|
||||
printf("Could not find an orientation sensor!\n");
|
||||
|
||||
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_GYROSCOPE);
|
||||
if (!sens) printf("can't find an gyroscope sensor!\n");
|
||||
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);
|
||||
eeze_sensor_free(sens);
|
||||
if (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("Gyroscope output: accuracy %i, x %f, y %f, z %f at time: %lli\n", acc, x, y, z, timestamp);
|
||||
eeze_sensor_free(sens);
|
||||
}
|
||||
else
|
||||
printf("Could not find a gyroscope sensor!\n");
|
||||
|
||||
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_PROXIMITY);
|
||||
if (!sens) printf("can't find an proximity sensor!\n");
|
||||
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);
|
||||
eeze_sensor_free(sens);
|
||||
if (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("Proximity output: accuracy %i, distance %f at time: %lli\n", acc, x, timestamp);
|
||||
eeze_sensor_free(sens);
|
||||
}
|
||||
else
|
||||
printf("Could not find a proximity sensor!\n");
|
||||
|
||||
sens = eeze_sensor_new(EEZE_SENSOR_TYPE_LIGHT);
|
||||
if (!sens) printf("can't find an light sensor!\n");
|
||||
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);
|
||||
if (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("Light output: accuracy %i, lux %f at time: %lli\n", acc, x, timestamp);
|
||||
}
|
||||
else
|
||||
printf("Could not find a light sensor!\n");
|
||||
|
||||
sleep(1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue