Fix sensor deactivation and take abs value for proper rotation

Signed-off-by: Michael Trimarchi <mich...@panicking.kicks-ass.org>

---
diff --git a/sensors/sensors_freerunner.c b/sensors/sensors_freerunner.c
index 9413fea..191c777 100644
--- a/sensors/sensors_freerunner.c
+++ b/sensors/sensors_freerunner.c
@@ -225,7 +225,7 @@ static int control_activate(struct sensors_control_device_t *dev,
     if (!enabled)
     {
         LOGD("Deactivate sensor\n");
-        value = 8000;
+        value = 8001;
     }
     else
         LOGD("Activate sensor\n");
@@ -318,15 +318,15 @@ int sensors_poll(struct sensors_data_device_t *dev, sensors_data_t* values)
             {
             case ABS_X:
                 new_sensors |= ACCELERATION_X;
-                sensors.acceleration.x = ev.value * CONVERT;
+                sensors.acceleration.x = abs(ev.value * CONVERT);
                 break;
             case ABS_Y:
                 new_sensors |= ACCELERATION_Y;
-                sensors.acceleration.y = ev.value * CONVERT;
+                sensors.acceleration.y = abs(ev.value * CONVERT);
                 break;
             case ABS_Z:
                 new_sensors |= ACCELERATION_Z;
-                sensors.acceleration.z = ev.value * CONVERT;
+                sensors.acceleration.z = abs(ev.value * CONVERT);
                 break;
             }
         }
@@ -379,9 +379,7 @@ static int open_sensors(const struct hw_module_t* module, char const* name,
         sensor_fd = -1;
         *device = &device_control->common;
         status = 0;
-    }
-    else if (!strcmp(name, SENSORS_HARDWARE_DATA))
-{
+     } else if (!strcmp(name, SENSORS_HARDWARE_DATA)) {
         struct sensors_data_device_t *device_data =
                         malloc(sizeof(struct sensors_data_device_t));
         memset(device_data, 0, sizeof(*device_data));
_______________________________________________
android-freerunner mailing list
android-freerunner@android.koolu.org
http://android.koolu.org/listinfo.cgi/android-freerunner-koolu.org

Reply via email to