altos: When missing MMA655x, create fake Z accel value
authorKeith Packard <keithp@keithp.com>
Sat, 13 Oct 2012 22:02:42 +0000 (15:02 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 13 Oct 2012 22:02:42 +0000 (15:02 -0700)
This avoids overwriting the MPU6000 y acceleration value so that other
computations using that value can work unmodified.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao_data.h

index 1153d433669facdfbd58790367d526d504c6a4a6..86acd48fa8c94fe92e076bf7aa15da771c219910 100644 (file)
@@ -67,6 +67,9 @@ struct ao_data {
 #endif
 #if HAS_MPU6000
        struct ao_mpu6000_sample        mpu6000;
+#if !HAS_MMA655X
+       int16_t                         z_accel;
+#endif
 #endif
 #if HAS_HMC5883
        struct ao_hmc5883_sample        hmc5883;
@@ -285,9 +288,9 @@ typedef int16_t accel_t;
 typedef int16_t accel_t;
 
 /* MPU6000 is hooked up so that positive y is positive acceleration */
-#define ao_data_accel(packet)                  ((packet)->mpu6000.accel_y)
+#define ao_data_accel(packet)                  ((packet)->z_accel)
 #define ao_data_accel_cook(packet)             (-(packet)->mpu6000.accel_y)
-#define ao_data_set_accel(packet, accel)       ((packet)->mpu6000.accel_y = (accel))
+#define ao_data_set_accel(packet, accel)       ((packet)->z_accel = (accel))
 #define ao_data_accel_invert(a)                        (-(a))
 
 #endif