diff --git a/src/main/fc/rc_adjustments.c b/src/main/fc/rc_adjustments.c index 69c04174b..62669bb66 100644 --- a/src/main/fc/rc_adjustments.c +++ b/src/main/fc/rc_adjustments.c @@ -45,7 +45,7 @@ #include "fc/rc_adjustments.h" #include "fc/rc_controls.h" -#include "fc/rc_curves.h" +#include "fc/fc_rc.h" #include "fc/config.h" #include "rx/rx.h" @@ -254,6 +254,7 @@ static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t case ADJUSTMENT_THROTTLE_EXPO: newValue = constrain((int)controlRateConfig->thrExpo8 + delta, 0, 100); // FIXME magic numbers repeated in cli.c controlRateConfig->thrExpo8 = newValue; + generateThrottleCurve(); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_THROTTLE_EXPO, newValue); break; case ADJUSTMENT_PITCH_ROLL_RATE: diff --git a/src/main/fc/rc_curves.c b/src/main/fc/rc_curves.c deleted file mode 100644 index 84b437b22..000000000 --- a/src/main/fc/rc_curves.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of Cleanflight. - * - * Cleanflight is free software: you can redistribute it and/or modify - * it 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 is distributed in the hope that it 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 Cleanflight. If not, see . - */ - -#include -#include - -#include "platform.h" - -#include "config/feature.h" - -#include "io/motors.h" - -#include "fc/config.h" -#include "fc/rc_curves.h" -#include "fc/rc_controls.h" - -#include "rx/rx.h" - - -#define THROTTLE_LOOKUP_LENGTH 12 -static int16_t lookupThrottleRC[THROTTLE_LOOKUP_LENGTH]; // lookup table for expo & mid THROTTLE - -void generateThrottleCurve(controlRateConfig_t *controlRateConfig, const motorConfig_t *motorConfig) -{ - uint8_t i; - uint16_t minThrottle = (feature(FEATURE_3D && IS_RC_MODE_ACTIVE(BOX3DDISABLESWITCH)) ? PWM_RANGE_MIN : motorConfig->minthrottle); - - for (i = 0; i < THROTTLE_LOOKUP_LENGTH; i++) { - int16_t tmp = 10 * i - controlRateConfig->thrMid8; - uint8_t y = 1; - if (tmp > 0) - y = 100 - controlRateConfig->thrMid8; - if (tmp < 0) - y = controlRateConfig->thrMid8; - lookupThrottleRC[i] = 10 * controlRateConfig->thrMid8 + tmp * (100 - controlRateConfig->thrExpo8 + (int32_t) controlRateConfig->thrExpo8 * (tmp * tmp) / (y * y)) / 10; - lookupThrottleRC[i] = minThrottle + (int32_t) (motorConfig->maxthrottle - minThrottle) * lookupThrottleRC[i] / 1000; // [MINTHROTTLE;MAXTHROTTLE] - } -} - -int16_t rcLookupThrottle(int32_t tmp) -{ - const int32_t tmp2 = tmp / 100; - // [0;1000] -> expo -> [MINTHROTTLE;MAXTHROTTLE] - return lookupThrottleRC[tmp2] + (tmp - tmp2 * 100) * (lookupThrottleRC[tmp2 + 1] - lookupThrottleRC[tmp2]) / 100; -} - diff --git a/src/main/fc/rc_curves.h b/src/main/fc/rc_curves.h deleted file mode 100644 index c13851969..000000000 --- a/src/main/fc/rc_curves.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of Cleanflight. - * - * Cleanflight is free software: you can redistribute it and/or modify - * it 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 is distributed in the hope that it 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 Cleanflight. If not, see . - */ - -#pragma once - -struct controlRateConfig_s; -struct motorConfig_s; -void generateThrottleCurve(struct controlRateConfig_s *controlRateConfig, const struct motorConfig_s *motorConfig); - -int16_t rcLookupThrottle(int32_t tmp); - diff --git a/src/main/target/BETAFLIGHTF3/config.c b/src/main/target/BETAFLIGHTF3/config.c index b65b136e0..e7b417c39 100755 --- a/src/main/target/BETAFLIGHTF3/config.c +++ b/src/main/target/BETAFLIGHTF3/config.c @@ -20,25 +20,11 @@ #include -#include "common/utils.h" - -#include "drivers/io.h" - -#include "fc/rc_controls.h" - -#include "flight/failsafe.h" -#include "flight/mixer.h" -#include "flight/pid.h" - -#include "rx/rx.h" - -#include "config/config_profile.h" #include "config/config_master.h" +#include "config/feature.h" void targetConfiguration(master_t *config) { - UNUSED(config); - - batteryConfig->currentMeterScale = 235; + config->batteryConfig.currentMeterScale = 235; }