vtx: fix VTX_SETTINGS_POWER_COUNT and add dummy entries to saPowerNames
[inav.git] / src / main / fc / controlrate_profile.c
blobc8b144e136c7e2f507cd7f0b595d70d862432bbb
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdbool.h>
19 #include <stdint.h>
21 #include "platform.h"
23 #include "common/axis.h"
25 #include "config/config_reset.h"
26 #include "config/parameter_group.h"
27 #include "config/parameter_group_ids.h"
29 #include "fc/config.h"
30 #include "fc/controlrate_profile.h"
31 #include "fc/rc_curves.h"
32 #include "fc/settings.h"
34 const controlRateConfig_t *currentControlRateProfile;
37 PG_REGISTER_ARRAY_WITH_RESET_FN(controlRateConfig_t, MAX_CONTROL_RATE_PROFILE_COUNT, controlRateProfiles, PG_CONTROL_RATE_PROFILES, 4);
39 void pgResetFn_controlRateProfiles(controlRateConfig_t *instance)
41 for (int i = 0; i < MAX_CONTROL_RATE_PROFILE_COUNT; i++) {
42 RESET_CONFIG(controlRateConfig_t, &instance[i],
43 .throttle = {
44 .rcMid8 = SETTING_THR_MID_DEFAULT,
45 .rcExpo8 = SETTING_THR_EXPO_DEFAULT,
46 .dynPID = SETTING_TPA_RATE_DEFAULT,
47 .dynPID_on_YAW = SETTING_TPA_ON_YAW_DEFAULT,
48 .pa_breakpoint = SETTING_TPA_BREAKPOINT_DEFAULT,
49 .fixedWingTauMs = SETTING_FW_TPA_TIME_CONSTANT_DEFAULT
52 .stabilized = {
53 .rcExpo8 = SETTING_RC_EXPO_DEFAULT,
54 .rcYawExpo8 = SETTING_RC_YAW_EXPO_DEFAULT,
55 .rates[FD_ROLL] = SETTING_ROLL_RATE_DEFAULT,
56 .rates[FD_PITCH] = SETTING_PITCH_RATE_DEFAULT,
57 .rates[FD_YAW] = SETTING_YAW_RATE_DEFAULT,
60 .manual = {
61 .rcExpo8 = SETTING_MANUAL_RC_EXPO_DEFAULT,
62 .rcYawExpo8 = SETTING_MANUAL_RC_YAW_EXPO_DEFAULT,
63 .rates[FD_ROLL] = SETTING_MANUAL_ROLL_RATE_DEFAULT,
64 .rates[FD_PITCH] = SETTING_MANUAL_PITCH_RATE_DEFAULT,
65 .rates[FD_YAW] = SETTING_MANUAL_YAW_RATE_DEFAULT
68 .misc = {
69 .fpvCamAngleDegrees = SETTING_FPV_MIX_DEGREES_DEFAULT
71 #ifdef USE_RATE_DYNAMICS
72 .rateDynamics = {
73 .sensitivityCenter = SETTING_RATE_DYNAMICS_CENTER_SENSITIVITY_DEFAULT,
74 .sensitivityEnd = SETTING_RATE_DYNAMICS_END_SENSITIVITY_DEFAULT,
75 .correctionCenter = SETTING_RATE_DYNAMICS_CENTER_CORRECTION_DEFAULT,
76 .correctionEnd = SETTING_RATE_DYNAMICS_END_CORRECTION_DEFAULT,
77 .weightCenter = SETTING_RATE_DYNAMICS_CENTER_WEIGHT_DEFAULT,
78 .weightEnd = SETTING_RATE_DYNAMICS_END_WEIGHT_DEFAULT,
80 #endif
85 void setControlRateProfile(uint8_t profileIndex)
87 if (profileIndex >= MAX_CONTROL_RATE_PROFILE_COUNT) {
88 profileIndex = 0;
90 currentControlRateProfile = controlRateProfiles(profileIndex);
93 void activateControlRateConfig(void)
95 generateThrottleCurve(currentControlRateProfile);
98 void changeControlRateProfile(uint8_t profileIndex)
100 setControlRateProfile(profileIndex);
101 activateControlRateConfig();