diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c index e6add62..fa55092 100644 --- a/src/iio-sensor-proxy.c +++ b/src/iio-sensor-proxy.c @@ -45,6 +45,9 @@ typedef struct { /* Accelerometer */ OrientationUp previous_orientation; + int previous_accel_x; + int previous_accel_y; + int previous_accel_z; /* Light */ gdouble previous_level; @@ -164,11 +167,13 @@ typedef enum { PROP_HAS_AMBIENT_LIGHT = 1 << 2, PROP_LIGHT_LEVEL = 1 << 3, PROP_HAS_COMPASS = 1 << 4, - PROP_COMPASS_HEADING = 1 << 5 + PROP_COMPASS_HEADING = 1 << 5, + PROP_ACCELEROMETER_RAW = 1 << 6, } PropertiesMask; #define PROP_ALL (PROP_HAS_ACCELEROMETER | \ PROP_ACCELEROMETER_ORIENTATION | \ + PROP_ACCELEROMETER_RAW | \ PROP_HAS_AMBIENT_LIGHT | \ PROP_LIGHT_LEVEL) #define PROP_ALL_COMPASS (PROP_HAS_COMPASS | \ @@ -208,6 +213,10 @@ send_dbus_event (SensorData *data, g_variant_builder_add (&props_builder, "{sv}", "AccelerometerOrientation", g_variant_new_string (orientation_to_string (data->previous_orientation))); } + if (mask & PROP_ACCELEROMETER_RAW) { + g_variant_builder_add (&props_builder, "{sv}", "AccelerometerRaw", + g_variant_new ("(iiix)", data->previous_accel_x, data->previous_accel_y, data->previous_accel_z, g_get_real_time())); + } if (mask & PROP_HAS_AMBIENT_LIGHT) { gboolean has_als; @@ -626,10 +635,22 @@ accel_changed_func (SensorDriver *driver, tmp = data->previous_orientation; data->previous_orientation = orientation; + send_dbus_event (data, PROP_ACCELEROMETER_ORIENTATION); g_debug ("Emitted orientation changed: from %s to %s", orientation_to_string (tmp), orientation_to_string (data->previous_orientation)); + + data->previous_accel_x = readings->accel_x; + data->previous_accel_y = readings->accel_y; + data->previous_accel_z = readings->accel_z; + send_dbus_event (data, PROP_ACCELEROMETER_RAW); + } else if (data->previous_accel_x != readings->accel_x || data->previous_accel_y != readings->accel_y || data->previous_accel_z != readings->accel_z) { + data->previous_accel_x = readings->accel_x; + data->previous_accel_y = readings->accel_y; + data->previous_accel_z = readings->accel_z; + + send_dbus_event (data, PROP_ACCELEROMETER_RAW); } } diff --git a/src/monitor-sensor.c b/src/monitor-sensor.c index 7eb35cc..ffe4743 100644 --- a/src/monitor-sensor.c +++ b/src/monitor-sensor.c @@ -37,6 +37,16 @@ properties_changed (GDBusProxy *proxy, g_print (" Accelerometer orientation changed: %s\n", g_variant_get_string (v, NULL)); g_variant_unref (v); } + if (g_variant_dict_contains (&dict, "AccelerometerRaw")) { + gint x, y, z; + gint64 time; + + v = g_dbus_proxy_get_cached_property (iio_proxy, "AccelerometerRaw"); + + g_variant_get (v, "(iiix)", &x, &y, &z, &time); + g_print (" Accelerometer raw changed: x=%d/y=%d/z=%d time=%ld\n", x, y, z, time); + g_variant_unref (v); + } if (g_variant_dict_contains (&dict, "HasAmbientLight")) { v = g_dbus_proxy_get_cached_property (iio_proxy, "HasAmbientLight"); if (g_variant_get_boolean (v))