Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / fc / rc_adjustments.h
blob669205f5541b6b8c309699337023f3f8064f65a5
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 <stdbool.h>
25 #include "fc/rc_modes.h"
27 #include "pg/pg.h"
29 typedef enum {
30 ADJUSTMENT_NONE = 0,
31 ADJUSTMENT_RC_RATE,
32 ADJUSTMENT_RC_EXPO,
33 ADJUSTMENT_THROTTLE_EXPO,
34 ADJUSTMENT_PITCH_ROLL_RATE,
35 ADJUSTMENT_YAW_RATE,
36 ADJUSTMENT_PITCH_ROLL_P,
37 ADJUSTMENT_PITCH_ROLL_I,
38 ADJUSTMENT_PITCH_ROLL_D,
39 ADJUSTMENT_YAW_P,
40 ADJUSTMENT_YAW_I,
41 ADJUSTMENT_YAW_D,
42 ADJUSTMENT_RATE_PROFILE,
43 ADJUSTMENT_PITCH_RATE,
44 ADJUSTMENT_ROLL_RATE,
45 ADJUSTMENT_PITCH_P,
46 ADJUSTMENT_PITCH_I,
47 ADJUSTMENT_PITCH_D,
48 ADJUSTMENT_ROLL_P,
49 ADJUSTMENT_ROLL_I,
50 ADJUSTMENT_ROLL_D,
51 ADJUSTMENT_RC_RATE_YAW,
52 ADJUSTMENT_PITCH_ROLL_F,
53 ADJUSTMENT_FEEDFORWARD_TRANSITION,
54 ADJUSTMENT_HORIZON_STRENGTH,
55 ADJUSTMENT_ROLL_RC_RATE,
56 ADJUSTMENT_PITCH_RC_RATE,
57 ADJUSTMENT_ROLL_RC_EXPO,
58 ADJUSTMENT_PITCH_RC_EXPO,
59 ADJUSTMENT_PID_AUDIO,
60 ADJUSTMENT_PITCH_F,
61 ADJUSTMENT_ROLL_F,
62 ADJUSTMENT_YAW_F,
63 ADJUSTMENT_OSD_PROFILE,
64 ADJUSTMENT_LED_PROFILE,
65 ADJUSTMENT_FUNCTION_COUNT
66 } adjustmentFunction_e;
68 typedef enum {
69 ADJUSTMENT_MODE_STEP,
70 ADJUSTMENT_MODE_SELECT
71 } adjustmentMode_e;
73 typedef union adjustmentConfig_u {
74 uint8_t step;
75 uint8_t switchPositions;
76 } adjustmentData_t;
78 typedef struct adjustmentConfig_s {
79 adjustmentFunction_e adjustmentFunction;
80 adjustmentMode_e mode;
81 adjustmentData_t data;
82 } adjustmentConfig_t;
84 #define MAX_ADJUSTMENT_RANGE_COUNT 30
86 typedef struct adjustmentRange_s {
87 // when aux channel is in range...
88 uint8_t auxChannelIndex;
89 channelRange_t range;
91 // ..then apply the adjustment function to the auxSwitchChannel ...
92 uint8_t adjustmentConfig;
93 uint8_t auxSwitchChannelIndex;
95 uint16_t adjustmentCenter;
96 uint16_t adjustmentScale;
97 } adjustmentRange_t;
99 PG_DECLARE_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges);
101 typedef struct timedAdjustmentState_s {
102 uint32_t timeoutAt;
103 uint8_t adjustmentRangeIndex;
104 bool ready;
105 } timedAdjustmentState_t;
107 typedef struct continuosAdjustmentState_s {
108 uint8_t adjustmentRangeIndex;
109 int16_t lastRcData;
110 } continuosAdjustmentState_t;
112 struct controlRateConfig_s;
113 void processRcAdjustments(struct controlRateConfig_s *controlRateConfig);
114 const char *getAdjustmentsRangeName(void);
115 int getAdjustmentsRangeValue(void);
116 void activeAdjustmentRangeReset(void);