rename fix: smoothStepUpTransition (#13768)
[betaflight.git] / src / main / fc / controlrate_profile.c
blob0add5622b542c9bd79d73869a52cca1bcf1f5b15
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <string.h>
25 #include "platform.h"
27 #include "common/axis.h"
29 #include "config/config_reset.h"
30 #include "pg/pg.h"
31 #include "pg/pg_ids.h"
33 #include "config/config.h"
34 #include "fc/controlrate_profile.h"
35 #include "fc/rc.h"
36 #include "fc/rc_controls.h"
38 controlRateConfig_t *currentControlRateProfile;
40 PG_REGISTER_ARRAY_WITH_RESET_FN(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles, PG_CONTROL_RATE_PROFILES, 6);
42 void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
44 for (int i = 0; i < CONTROL_RATE_PROFILE_COUNT; i++) {
45 RESET_CONFIG(controlRateConfig_t, &controlRateConfig[i],
46 .thrMid8 = 50,
47 .thrExpo8 = 0,
48 .rates_type = RATES_TYPE_ACTUAL,
49 .rcRates[FD_ROLL] = 7,
50 .rcRates[FD_PITCH] = 7,
51 .rcRates[FD_YAW] = 7,
52 .rcExpo[FD_ROLL] = 0,
53 .rcExpo[FD_PITCH] = 0,
54 .rcExpo[FD_YAW] = 0,
55 .rates[FD_ROLL] = 67,
56 .rates[FD_PITCH] = 67,
57 .rates[FD_YAW] = 67,
58 .throttle_limit_type = THROTTLE_LIMIT_TYPE_OFF,
59 .throttle_limit_percent = 100,
60 .rate_limit[FD_ROLL] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
61 .rate_limit[FD_PITCH] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
62 .rate_limit[FD_YAW] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
63 .profileName = { 0 },
64 .quickRatesRcExpo = 0,
69 const ratesSettingsLimits_t ratesSettingLimits[RATES_TYPE_COUNT] = {
70 [RATES_TYPE_BETAFLIGHT] = { 255, 100, 100 },
71 [RATES_TYPE_RACEFLIGHT] = { 200, 255, 100 },
72 [RATES_TYPE_KISS] = { 255, 99, 100 },
73 [RATES_TYPE_ACTUAL] = { 200, 200, 100 },
74 [RATES_TYPE_QUICK] = { 255, 200, 100 },
77 void loadControlRateProfile(void)
79 currentControlRateProfile = controlRateProfilesMutable(systemConfig()->activeRateProfile);
82 void changeControlRateProfile(uint8_t controlRateProfileIndex)
84 if (controlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT) {
85 systemConfigMutable()->activeRateProfile = controlRateProfileIndex;
88 loadControlRateProfile();
89 initRcProcessing();
92 void copyControlRateProfile(const uint8_t dstControlRateProfileIndex, const uint8_t srcControlRateProfileIndex)
94 if ((dstControlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT && srcControlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT)
95 && dstControlRateProfileIndex != srcControlRateProfileIndex
96 ) {
97 memcpy(controlRateProfilesMutable(dstControlRateProfileIndex), controlRateProfiles(srcControlRateProfileIndex), sizeof(controlRateConfig_t));