[gnome-color-manager: 19/80] huey: Return the ambient lighting in Lux, using my ColorMunki as a reference
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager: 19/80] huey: Return the ambient lighting in Lux, using my ColorMunki as a reference
- Date: Mon, 19 Jul 2010 11:34:03 +0000 (UTC)
commit 754af81213f4f6bc82a665c89d817e33e25ae03d
Author: Richard Hughes <richard hughsie com>
Date: Sat Jul 17 22:46:16 2010 +0100
huey: Return the ambient lighting in Lux, using my ColorMunki as a reference
src/gcm-huey-example.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/gcm-huey-example.c b/src/gcm-huey-example.c
index c724c7f..14a2b95 100644
--- a/src/gcm-huey-example.c
+++ b/src/gcm-huey-example.c
@@ -100,6 +100,8 @@
/* returns: all NULL for NULL input: times out for f1 f2 f3 f4 f5 f6 f7 f8 */
#define HUEY_COMMAND_UNKNOWN_19 0x19
+#define HUEY_AMBIENT_UNITS_TO_LUX 125.0f /* fudge factor */
+
typedef struct {
gboolean connected;
libusb_device *device;
@@ -338,7 +340,7 @@ send_leds (GcmPriv *priv, guchar mask, GError **error)
}
static gboolean
-get_ambient (GcmPriv *priv, guint16 *value, GError **error)
+get_ambient (GcmPriv *priv, gdouble *value, GError **error)
{
/* from usb-ambient.txt */
guchar request[] = { HUEY_COMMAND_AMBIENT, 0x03, 0x00, 0xa9, 0xaa, 0xaa, 0xab, 0xab };
@@ -353,7 +355,7 @@ get_ambient (GcmPriv *priv, guint16 *value, GError **error)
/* parse the value */
g_debug ("%i, %i", reply[5], reply[5]);
- *value = reply[5] * 0xff + reply[6];
+ *value = (gdouble) (reply[5] * 0xff + reply[6]) / HUEY_AMBIENT_UNITS_TO_LUX;
out:
return ret;
}
@@ -389,7 +391,7 @@ main (void)
{
gint retval;
guint i;
- guint16 value;
+ gdouble value;
gboolean ret;
GcmPriv *priv;
GError *error = NULL;
@@ -420,6 +422,7 @@ main (void)
goto out;
}
+if (0) {
/* this is done by the windows driver */
ret = read_registers (priv, &error);
if (!ret) {
@@ -427,6 +430,7 @@ main (void)
g_error_free (error);
goto out;
}
+}
/* set LEDs */
ret = send_leds (priv, 0x0f, &error);
@@ -443,7 +447,7 @@ main (void)
g_error_free (error);
goto out;
}
- g_debug ("ambient = %i(units?)", value);
+ g_debug ("ambient = %.1lf Lux", value);
if (0) {
guchar payload[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]