altos: Add new telemetry packet format for TeleMega v4
authorKeith Packard <keithp@keithp.com>
Wed, 12 Feb 2020 21:01:08 +0000 (13:01 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 13 Feb 2020 04:53:51 +0000 (20:53 -0800)
Bmx160 instead of MPU9250 changes orientation of IMU data

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_telemetry.c
src/kernel/ao_telemetry.h

index 2aceaf283c893fa49b10a4c2228ada1eb229c626..2092c84f403cd65606eeb78078a3d64d7f689ab6 100644 (file)
@@ -139,9 +139,17 @@ ao_send_mega_sensor(void)
                struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
 
        telemetry.generic.tick = packet->tick;
-       telemetry.generic.type = AO_TELEMETRY_MEGA_SENSOR;
-
+#if HAS_BMX160
+       telemetry.generic.type = AO_TELEMETRY_MEGA_SENSOR_BMX160;
+#else
 #if HAS_MPU6000 || HAS_MPU9250
+       telemetry.generic.type = AO_TELEMETRY_MEGA_SENSOR_MPU;
+#else
+#error unknown IMU
+#endif
+#endif
+
+#if HAS_GYRO
        telemetry.mega_sensor.orient = ao_sample_orient;
 #endif
        telemetry.mega_sensor.accel = ao_data_accel(packet);
@@ -178,6 +186,20 @@ ao_send_mega_sensor(void)
        telemetry.mega_sensor.mag_y = packet->mpu9250.mag_y;
 #endif
 
+#if HAS_BMX160
+       telemetry.mega_sensor.accel_x = packet->bmx160.acc_x;
+       telemetry.mega_sensor.accel_y = packet->bmx160.acc_y;
+       telemetry.mega_sensor.accel_z = packet->bmx160.acc_z;
+
+       telemetry.mega_sensor.gyro_x = packet->bmx160.gyr_x;
+       telemetry.mega_sensor.gyro_y = packet->bmx160.gyr_y;
+       telemetry.mega_sensor.gyro_z = packet->bmx160.gyr_z;
+
+       telemetry.mega_sensor.mag_x = packet->bmx160.mag_x;
+       telemetry.mega_sensor.mag_z = packet->bmx160.mag_z;
+       telemetry.mega_sensor.mag_y = packet->bmx160.mag_y;
+#endif
+
        ao_telemetry_send();
 }
 
index 23e3ed7db7c4a5309f4b76bc7d5db6da424a0a86..c7aebe599a317d86de65b5d8675f4694ea43cca8 100644 (file)
@@ -176,7 +176,8 @@ struct ao_telemetry_companion {
        /* 32 */
 };
 
-#define AO_TELEMETRY_MEGA_SENSOR       0x08
+#define AO_TELEMETRY_MEGA_SENSOR_MPU           0x08    /* Invensense IMU */
+#define AO_TELEMETRY_MEGA_SENSOR_BMX160                0x12    /* BMX160 IMU */
 
 struct ao_telemetry_mega_sensor {
        uint16_t        serial;         /*  0 */