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)
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/>.
27 #include "common/axis.h"
29 #include "config/config_reset.h"
31 #include "pg/pg_ids.h"
33 #include "config/config.h"
34 #include "fc/controlrate_profile.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
, 4);
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
],
49 .tpa_breakpoint
= 1350,
50 .rates_type
= RATES_TYPE_ACTUAL
,
51 .rcRates
[FD_ROLL
] = 7,
52 .rcRates
[FD_PITCH
] = 7,
55 .rcExpo
[FD_PITCH
] = 0,
58 .rates
[FD_PITCH
] = 67,
60 .throttle_limit_type
= THROTTLE_LIMIT_TYPE_OFF
,
61 .throttle_limit_percent
= 100,
62 .rate_limit
[FD_ROLL
] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX
,
63 .rate_limit
[FD_PITCH
] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX
,
64 .rate_limit
[FD_YAW
] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX
,
65 .tpaMode
= TPA_MODE_D
,
67 .quickRatesRcExpo
= 0,
68 .levelExpo
[FD_ROLL
] = 0,
69 .levelExpo
[FD_PITCH
] = 0,
74 const ratesSettingsLimits_t ratesSettingLimits
[RATES_TYPE_COUNT
] = {
75 [RATES_TYPE_BETAFLIGHT
] = { 255, 100, 100 },
76 [RATES_TYPE_RACEFLIGHT
] = { 200, 255, 100 },
77 [RATES_TYPE_KISS
] = { 255, 99, 100 },
78 [RATES_TYPE_ACTUAL
] = { 200, 200, 100 },
79 [RATES_TYPE_QUICK
] = { 255, 200, 100 },
82 void loadControlRateProfile(void)
84 currentControlRateProfile
= controlRateProfilesMutable(systemConfig()->activeRateProfile
);
87 void changeControlRateProfile(uint8_t controlRateProfileIndex
)
89 if (controlRateProfileIndex
< CONTROL_RATE_PROFILE_COUNT
) {
90 systemConfigMutable()->activeRateProfile
= controlRateProfileIndex
;
93 loadControlRateProfile();
97 void copyControlRateProfile(const uint8_t dstControlRateProfileIndex
, const uint8_t srcControlRateProfileIndex
)
99 if ((dstControlRateProfileIndex
< CONTROL_RATE_PROFILE_COUNT
&& srcControlRateProfileIndex
< CONTROL_RATE_PROFILE_COUNT
)
100 && dstControlRateProfileIndex
!= srcControlRateProfileIndex
102 memcpy(controlRateProfilesMutable(dstControlRateProfileIndex
), controlRateProfiles(srcControlRateProfileIndex
), sizeof(controlRateConfig_t
));