diff options
author | Richard Hughes <richard@hughsie.com> | 2015-10-13 13:30:09 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-10-13 16:23:22 +0100 |
commit | c6d4239217fffffac72c81047af24b3aa0a10122 (patch) | |
tree | b84c267815e43d0eaa219a01ce8756793a5d73cc /client | |
parent | 21eb54857e942ab8bccecd9914e19083dd57288b (diff) | |
download | colord-c6d4239217fffffac72c81047af24b3aa0a10122.tar.gz |
Add a sensor error for missing dark calibration
Diffstat (limited to 'client')
-rw-r--r-- | client/cd-util.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/client/cd-util.c b/client/cd-util.c index abad25b..b097ab9 100644 --- a/client/cd-util.c +++ b/client/cd-util.c @@ -1070,6 +1070,7 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) { CdColorXYZ *xyz; CdSensorCap cap; + CdSensorCap cap_tmp = CD_SENSOR_CAP_UNKNOWN; CdSensor *sensor; GError *error_local = NULL; guint i; @@ -1115,7 +1116,7 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) /* get 3 samples sync */ for (j = 1; j < 4; j++) { xyz = cd_sensor_get_sample_sync (sensor, - cap, + cap_tmp ? cap_tmp : cap, NULL, &error_local); if (xyz == NULL) { @@ -1137,6 +1138,16 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) j--; g_clear_error (&error_local); continue; + } else if (g_error_matches (error_local, + CD_SENSOR_ERROR, + CD_SENSOR_ERROR_REQUIRED_DARK_CALIBRATION)) { + /* TRANSLATORS: the user needs to change something on the device */ + g_print ("%s\n", _("Put the device in a dark place and press enter.")); + getchar (); + j--; + g_clear_error (&error_local); + cap_tmp = CD_SENSOR_CAP_CALIBRATION; + continue; } else { g_propagate_error (error, error_local); @@ -1144,6 +1155,13 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) } } + /* reset back */ + if (cap_tmp == CD_SENSOR_CAP_CALIBRATION) { + cap_tmp = CD_SENSOR_CAP_UNKNOWN; + g_print ("%s\n", _("Put the device on the color to be measured and press enter.")); + getchar (); + } + /* TRANSLATORS: this is the XYZ color value */ g_print ("%s XYZ : %f, %f, %f\n", _("Color"), |