From 87bceb72f14af31aba04b95692e41775d3788a79 Mon Sep 17 00:00:00 2001 From: g122622 <3300925806@qq.com> Date: Tue, 30 Apr 2024 12:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=99=90=E5=88=B6=E8=A7=92?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E6=84=9F=E7=9F=A5=E8=8C=83=E5=9B=B4=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/mpu6050/motionData.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main/mpu6050/motionData.h b/main/mpu6050/motionData.h index e7929a8..a616160 100644 --- a/main/mpu6050/motionData.h +++ b/main/mpu6050/motionData.h @@ -4,7 +4,7 @@ * Created Date: 2024-03-07 22:51:03 * Author: Guoyi * ----- - * Last Modified: 2024-04-29 23:53:44 + * Last Modified: 2024-04-30 00:31:36 * Modified By: Guoyi * ----- * Copyright (c) 2024 Guoyi Inc. @@ -23,7 +23,9 @@ #include "LED/StatusLED.h" #include "./algorithm/slidingFilter.h" -#define MIN(X,Y) ((X)<(Y)?(X):(Y)) +#define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) +#define LIMIT(X, Y) (MAX(MIN(X, Y), (-1) * Y)) // 将X的绝对值限制在Y以内 #define ACCEL_RANGE 2 #define GYRO_RANGE 250 @@ -124,9 +126,9 @@ F3D getGyroData() { // 限制角速度感知范围 F3D ret = { - .x = MIN(MPU6050_Get_16bit_Data(GYRO_XOUT_H) / (double)(65536 / 2 / GYRO_RANGE) - CalibrationOffset.gx, 120), - .y = MIN(MPU6050_Get_16bit_Data(GYRO_YOUT_H) / (double)(65536 / 2 / GYRO_RANGE) - CalibrationOffset.gy, 120), - .z = MIN(MPU6050_Get_16bit_Data(GYRO_ZOUT_H) / (double)(65536 / 2 / GYRO_RANGE) - CalibrationOffset.gz, 120), + .x = LIMIT(MPU6050_Get_16bit_Data(GYRO_XOUT_H) / (double)(65536 / 2 / GYRO_RANGE) - CalibrationOffset.gx, 120), + .y = LIMIT(MPU6050_Get_16bit_Data(GYRO_YOUT_H) / (double)(65536 / 2 / GYRO_RANGE) - CalibrationOffset.gy, 120), + .z = LIMIT(MPU6050_Get_16bit_Data(GYRO_ZOUT_H) / (double)(65536 / 2 / GYRO_RANGE) - CalibrationOffset.gz, 120), }; return ret; }