altos: Support normalized axes in mpu6000 and mmc5983
authorKeith Packard <keithp@keithp.com>
Sun, 19 Sep 2021 21:50:28 +0000 (14:50 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 19 Sep 2021 21:50:28 +0000 (14:50 -0700)
For monitor idle, devices selecting 'normalized' log format also
get 'normalized' command mode. This reports data in a standard format,
along/across/through instead of raw device axes which depend on how the
part is mounted.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_mmc5983.c
src/drivers/ao_mpu6000.c

index e27051a5173c852c5d41f7218987049bee022f72..5d97d757f3fd1fedaeafcf300f7428c0de12c060 100644 (file)
@@ -202,9 +202,10 @@ static struct ao_task ao_mmc5983_task;
 static void
 ao_mmc5983_show(void)
 {
 static void
 ao_mmc5983_show(void)
 {
-       printf ("X: %d Z: %d Y: %d id: %d\n",
-               ao_mmc5983_current.x, ao_mmc5983_current.z, ao_mmc5983_current.y,
-               product_id);
+       printf ("MMC5983: %d %d %d\n",
+               ao_mmc5983_along(&ao_mmc5983_current),
+               ao_mmc5983_across(&ao_mmc5983_current),
+               ao_mmc5983_through(&ao_mmc5983_current));
 }
 
 static const struct ao_cmds ao_mmc5983_cmds[] = {
 }
 
 static const struct ao_cmds ao_mmc5983_cmds[] = {
index dd3da8dee3837f504a6df05d4633a0d5e03bf9cf..79658c552bf2e38b7c917d287523f148df86d271 100644 (file)
@@ -357,14 +357,23 @@ static struct ao_task ao_mpu6000_task;
 static void
 ao_mpu6000_show(void)
 {
 static void
 ao_mpu6000_show(void)
 {
-       printf ("Accel: %7d %7d %7d Gyro: %7d %7d %7d id %02x\n",
+#ifdef AO_LOG_NORMALIZED
+       printf ("MPU6000: %7d %7d %7d %7d %7d %7d\n",
+               ao_mpu6000_along(&ao_mpu6000_current),
+               ao_mpu6000_across(&ao_mpu6000_current),
+               ao_mpu6000_through(&ao_mpu6000_current),
+               ao_mpu6000_roll(&ao_mpu6000_current),
+               ao_mpu6000_pitch(&ao_mpu6000_current),
+               ao_mpu6000_yaw(&ao_mpu6000_current));
+#else
+       printf ("Accel: %7d %7d %7d Gyro: %7d %7d %7d\n",
                ao_mpu6000_current.accel_x,
                ao_mpu6000_current.accel_y,
                ao_mpu6000_current.accel_z,
                ao_mpu6000_current.gyro_x,
                ao_mpu6000_current.gyro_y,
                ao_mpu6000_current.accel_x,
                ao_mpu6000_current.accel_y,
                ao_mpu6000_current.accel_z,
                ao_mpu6000_current.gyro_x,
                ao_mpu6000_current.gyro_y,
-               ao_mpu6000_current.gyro_z,
-               mpu_id);
+               ao_mpu6000_current.gyro_z);
+#endif
 }
 
 static const struct ao_cmds ao_mpu6000_cmds[] = {
 }
 
 static const struct ao_cmds ao_mpu6000_cmds[] = {