Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / fc / controlrate_profile.h
blob107e1626629500d9b70c5a18da65e5faf4439641
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 #pragma once
23 #include <stdint.h>
25 #include "pg/pg.h"
27 typedef enum {
28 RATES_TYPE_BETAFLIGHT = 0,
29 RATES_TYPE_RACEFLIGHT,
30 RATES_TYPE_KISS,
31 RATES_TYPE_ACTUAL,
32 RATES_TYPE_QUICK,
33 RATES_TYPE_COUNT // must be the final entry
34 } ratesType_e;
36 typedef struct ratesSettingsLimits_s {
37 uint8_t rc_rate_limit;
38 uint8_t srate_limit;
39 uint8_t expo_limit;
40 } ratesSettingsLimits_t;
42 typedef enum {
43 THROTTLE_LIMIT_TYPE_OFF = 0,
44 THROTTLE_LIMIT_TYPE_SCALE,
45 THROTTLE_LIMIT_TYPE_CLIP,
46 THROTTLE_LIMIT_TYPE_COUNT // must be the last entry
47 } throttleLimitType_e;
49 typedef enum {
50 TPA_MODE_PD,
51 TPA_MODE_D
52 } tpaMode_e;
54 #define MAX_RATE_PROFILE_NAME_LENGTH 8u
56 typedef struct controlRateConfig_s {
57 uint8_t thrMid8;
58 uint8_t thrExpo8;
59 uint8_t rates_type;
60 uint8_t rcRates[3];
61 uint8_t rcExpo[3];
62 uint8_t rates[3];
63 uint8_t dynThrPID;
64 uint16_t tpa_breakpoint; // Breakpoint where TPA is activated
65 uint8_t throttle_limit_type; // Sets the throttle limiting type - off, scale or clip
66 uint8_t throttle_limit_percent; // Sets the maximum pilot commanded throttle limit
67 uint16_t rate_limit[3]; // Sets the maximum rate for the axes
68 uint8_t tpaMode; // Controls which PID terms TPA effects
69 char profileName[MAX_RATE_PROFILE_NAME_LENGTH + 1]; // Descriptive name for rate profile
70 uint8_t quickRatesRcExpo; // Sets expo on rc command for quick rates
71 uint8_t levelExpo[2]; // roll/pitch level mode expo
72 } controlRateConfig_t;
74 PG_DECLARE_ARRAY(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
76 extern controlRateConfig_t *currentControlRateProfile;
77 extern const ratesSettingsLimits_t ratesSettingLimits[RATES_TYPE_COUNT];
79 void loadControlRateProfile(void);
80 void changeControlRateProfile(uint8_t controlRateProfileIndex);
82 void copyControlRateProfile(const uint8_t dstControlRateProfileIndex, const uint8_t srcControlRateProfileIndex);