diff options
author | Richard Hughes <richard@hughsie.com> | 2012-11-28 15:52:03 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2012-11-28 15:52:03 +0000 |
commit | 7bd5cc7a8ae12545f1df79a7834b409185b0553f (patch) | |
tree | 3caee0cb2767ca6d33a23b89658f3ebeecd367f9 /client/cd-util.c | |
parent | d74b8c6dcd66a80f0e267c3aba6ac1668caa8b9a (diff) | |
download | colord-7bd5cc7a8ae12545f1df79a7834b409185b0553f.tar.gz |
Do 3 reads in quick succession for colormgr get-sensor-reading
Diffstat (limited to 'client/cd-util.c')
-rw-r--r-- | client/cd-util.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/client/cd-util.c b/client/cd-util.c index a0aea82..89a1c46 100644 --- a/client/cd-util.c +++ b/client/cd-util.c @@ -812,6 +812,7 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) // gdouble ambient; GPtrArray *array = NULL; guint i; + guint j; if (g_strv_length (values) < 1) { ret = FALSE; @@ -837,13 +838,18 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) goto out; } cap = cd_sensor_cap_from_string (values[0]); - for (i=0; i < array->len; i++) { + for (i = 0; i < array->len; i++) { sensor = g_ptr_array_index (array, i); ret = cd_sensor_connect_sync (sensor, NULL, error); if (!ret) goto out; + /* TRANSLATORS: this is the sensor title */ + g_print ("%s: %s - %s\n", _("Sensor"), + cd_sensor_get_vendor (sensor), + cd_sensor_get_model (sensor)); + /* lock */ ret = cd_sensor_lock_sync (sensor, NULL, @@ -851,14 +857,22 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) if (!ret) goto out; - /* get a sample sync */ - xyz = cd_sensor_get_sample_sync (sensor, - cap, - NULL, - error); - if (xyz == NULL) { - ret = FALSE; - goto out; + /* get 3 samples sync */ + for (j = 0; j < 3; j++) { + xyz = cd_sensor_get_sample_sync (sensor, + cap, + NULL, + error); + if (xyz == NULL) { + ret = FALSE; + goto out; + } + + /* TRANSLATORS: this is the XYZ color value */ + g_print ("%s XYZ : %f, %f, %f\n", + _("Color"), + xyz->X, xyz->Y, xyz->Z); + cd_color_xyz_free (xyz); } /* unlock */ @@ -868,21 +882,10 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) if (!ret) goto out; - /* TRANSLATORS: this is the sensor title */ - g_print ("%s: %s - %s\n", _("Sensor"), - cd_sensor_get_vendor (sensor), - cd_sensor_get_model (sensor)); - /* TRANSLATORS: this is the ambient light level in Lux */ // g_print ("%s: %f Lux\n", // _("Ambient"), // ambient); - - /* TRANSLATORS: this is the XYZ color value */ - g_print ("%s XYZ : %f, %f, %f\n", - _("Color"), - xyz->X, xyz->Y, xyz->Z); - cd_color_xyz_free (xyz); } out: if (array != NULL) |