[gnome-color-manager: 79/80] huey: when we start the device, spin the LEDs like argyll and the Windows driver does



commit b734530507f78ca95176de90db70b682ca9d3106
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 19 12:31:41 2010 +0100

    huey: when we start the device, spin the LEDs like argyll and the Windows driver does

 libcolor-glib/gcm-sensor-huey.c |    9 +++++++++
 src/gcm-huey-example.c          |   17 -----------------
 2 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/libcolor-glib/gcm-sensor-huey.c b/libcolor-glib/gcm-sensor-huey.c
index 38b78ad..948ce03 100644
--- a/libcolor-glib/gcm-sensor-huey.c
+++ b/libcolor-glib/gcm-sensor-huey.c
@@ -764,9 +764,11 @@ static gboolean
 gcm_sensor_huey_startup (GcmSensor *sensor, GError **error)
 {
 	gboolean ret = FALSE;
+	guint i;
 	gint retval;
 	GcmSensorHuey *sensor_huey = GCM_SENSOR_HUEY (sensor);
 	GcmSensorHueyPrivate *priv = sensor_huey->priv;
+	const guint8 spin_leds[] = { 0x0, 0x1, 0x2, 0x4, 0x8, 0x4, 0x2, 0x1, 0x0, 0xff };
 
 	/* connect */
 	retval = libusb_init (&priv->ctx);
@@ -805,6 +807,13 @@ gcm_sensor_huey_startup (GcmSensor *sensor, GError **error)
 		goto out;
 	egg_debug ("device matrix2: %s", gcm_mat33_to_string (&priv->calibration_matrix2));
 
+	/* spin the LEDs */
+	for (i=0; spin_leds[i] != 0xff; i++) {
+		ret = gcm_sensor_huey_set_leds (sensor, spin_leds[i], error);
+		if (!ret)
+			goto out;
+		g_usleep (50000);
+	}
 out:
 	return ret;
 }
diff --git a/src/gcm-huey-example.c b/src/gcm-huey-example.c
index 053cb09..6f9c859 100644
--- a/src/gcm-huey-example.c
+++ b/src/gcm-huey-example.c
@@ -45,14 +45,6 @@ main (void)
 	/* create new sensor */
 	sensor = gcm_sensor_huey_new ();
 
-	/* set LEDs */
-	ret = gcm_sensor_set_leds (sensor, 0x0f, &error);
-	if (!ret) {
-		g_warning ("failed to send leds: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
 	/* set mode */
 	gcm_sensor_set_output_type (sensor, GCM_SENSOR_OUTPUT_TYPE_LCD);
 
@@ -73,15 +65,6 @@ main (void)
 		goto out;
 	}
 	g_debug ("X=%0.4lf, Y=%0.4lf, Z=%0.4lf", values.X, values.Y, values.Z);
-
-	/* set LEDs */
-	ret = gcm_sensor_set_leds (sensor, 0x00, &error);
-	if (!ret) {
-		g_warning ("failed to send leds: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
 out:
 	g_object_unref (sensor);
 	return 0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]