Fix WS2812 led definition
[inav.git] / src / main / fc / controlrate_profile.c
blob18f5bd343b6d4e1e050a73f7f818fe9aeec8d603
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 .pa_breakpoint = SETTING_TPA_BREAKPOINT_DEFAULT,
48 .fixedWingTauMs = SETTING_FW_TPA_TIME_CONSTANT_DEFAULT
51 .stabilized = {
52 .rcExpo8 = SETTING_RC_EXPO_DEFAULT,
53 .rcYawExpo8 = SETTING_RC_YAW_EXPO_DEFAULT,
54 .rates[FD_ROLL] = SETTING_ROLL_RATE_DEFAULT,
55 .rates[FD_PITCH] = SETTING_PITCH_RATE_DEFAULT,
56 .rates[FD_YAW] = SETTING_YAW_RATE_DEFAULT,
59 .manual = {
60 .rcExpo8 = SETTING_MANUAL_RC_EXPO_DEFAULT,
61 .rcYawExpo8 = SETTING_MANUAL_RC_YAW_EXPO_DEFAULT,
62 .rates[FD_ROLL] = SETTING_MANUAL_ROLL_RATE_DEFAULT,
63 .rates[FD_PITCH] = SETTING_MANUAL_PITCH_RATE_DEFAULT,
64 .rates[FD_YAW] = SETTING_MANUAL_YAW_RATE_DEFAULT
67 .misc = {
68 .fpvCamAngleDegrees = SETTING_FPV_MIX_DEGREES_DEFAULT
70 #ifdef USE_RATE_DYNAMICS
71 .rateDynamics = {
72 .sensitivityCenter = SETTING_RATE_DYNAMICS_CENTER_SENSITIVITY_DEFAULT,
73 .sensitivityEnd = SETTING_RATE_DYNAMICS_END_SENSITIVITY_DEFAULT,
74 .correctionCenter = SETTING_RATE_DYNAMICS_CENTER_CORRECTION_DEFAULT,
75 .correctionEnd = SETTING_RATE_DYNAMICS_END_CORRECTION_DEFAULT,
76 .weightCenter = SETTING_RATE_DYNAMICS_CENTER_WEIGHT_DEFAULT,
77 .weightEnd = SETTING_RATE_DYNAMICS_END_WEIGHT_DEFAULT,
79 #endif
84 void setControlRateProfile(uint8_t profileIndex)
86 if (profileIndex >= MAX_CONTROL_RATE_PROFILE_COUNT) {
87 profileIndex = 0;
89 currentControlRateProfile = controlRateProfiles(profileIndex);
92 void activateControlRateConfig(void)
94 generateThrottleCurve(currentControlRateProfile);
97 void changeControlRateProfile(uint8_t profileIndex)
99 setControlRateProfile(profileIndex);
100 activateControlRateConfig();