From 75ccb897f19417af2d6b9a48452c541498935890 Mon Sep 17 00:00:00 2001 From: ZhengNingwei Date: Mon, 27 Aug 2018 13:57:06 +0800 Subject: [PATCH 1/2] Change DALRCF722DUAL gyroMovementCalibrationThreshold default value Add config.c file to setup ICM20602's calibration threshold 148.When FC switch GYRO_CONFIG_USE_GYRO_1,it recover default value 48. The function targetValidateConfiguration() will executes every time,so Increased judgment to check,avoid CLI set fail. --- src/main/target/DALRCF722DUAL/config.c | 45 ++++++++++++++++++++++++++ src/main/target/DALRCF722DUAL/target.h | 1 + 2 files changed, 46 insertions(+) create mode 100644 src/main/target/DALRCF722DUAL/config.c diff --git a/src/main/target/DALRCF722DUAL/config.c b/src/main/target/DALRCF722DUAL/config.c new file mode 100644 index 0000000000..fa01d76ca1 --- /dev/null +++ b/src/main/target/DALRCF722DUAL/config.c @@ -0,0 +1,45 @@ +/* + * This file is part of Cleanflight and Betaflight. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software under the terms of the + * GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Cleanflight and Betaflight are distributed in the hope that they + * will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software. + * + * If not, see . + */ + +#include + +#include "platform.h" + + +#ifdef TARGET_VALIDATECONFIG + +#include "fc/config.h" + +#include "sensors/gyro.h" + +void targetValidateConfiguration(void) +{ + if(gyroConfigMutable()->gyro_to_use == GYRO_CONFIG_USE_GYRO_2) { + if((gyroConfigMutable()->gyroMovementCalibrationThreshold ==48) && (gyroConfigMutable()->gyroMovementCalibrationThreshold !=148)) { + gyroConfigMutable()->gyroMovementCalibrationThreshold = 148; //for cli set + } + } else { + if((gyroConfigMutable()->gyroMovementCalibrationThreshold ==148) && (gyroConfigMutable()->gyroMovementCalibrationThreshold !=48)) { + gyroConfigMutable()->gyroMovementCalibrationThreshold = 48; //for cli set + } + } +} + +#endif diff --git a/src/main/target/DALRCF722DUAL/target.h b/src/main/target/DALRCF722DUAL/target.h index a92e26610c..da74cc38fc 100644 --- a/src/main/target/DALRCF722DUAL/target.h +++ b/src/main/target/DALRCF722DUAL/target.h @@ -19,6 +19,7 @@ */ #pragma once +#define TARGET_VALIDATECONFIG #define TARGET_BOARD_IDENTIFIER "DLF7" #define USBD_PRODUCT_STRING "DALRCF722DUAL" From 459f91e7a05400716fdcfff9f0f1dc4b8340ec7c Mon Sep 17 00:00:00 2001 From: NywayZheng Date: Mon, 27 Aug 2018 22:28:06 +0800 Subject: [PATCH 2/2] Update config.c --- src/main/target/DALRCF722DUAL/config.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/target/DALRCF722DUAL/config.c b/src/main/target/DALRCF722DUAL/config.c index fa01d76ca1..f07d7206a9 100644 --- a/src/main/target/DALRCF722DUAL/config.c +++ b/src/main/target/DALRCF722DUAL/config.c @@ -31,14 +31,8 @@ void targetValidateConfiguration(void) { - if(gyroConfigMutable()->gyro_to_use == GYRO_CONFIG_USE_GYRO_2) { - if((gyroConfigMutable()->gyroMovementCalibrationThreshold ==48) && (gyroConfigMutable()->gyroMovementCalibrationThreshold !=148)) { - gyroConfigMutable()->gyroMovementCalibrationThreshold = 148; //for cli set - } - } else { - if((gyroConfigMutable()->gyroMovementCalibrationThreshold ==148) && (gyroConfigMutable()->gyroMovementCalibrationThreshold !=48)) { - gyroConfigMutable()->gyroMovementCalibrationThreshold = 48; //for cli set - } + if (gyroConfig()->gyro_use_32khz && gyroConfig()->gyroMovementCalibrationThreshold < 148) { + gyroConfigMutable()->gyroMovementCalibrationThreshold = 148; } }