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/>.
20 #include "config/parameter_group.h"
22 #define CONTROL_DEADBAND 10 // Used to check if sticks are centered
24 typedef enum rc_alias
{
59 THROTTLE_STATUS_TYPE_RC
= 0,
60 THROTTLE_STATUS_TYPE_COMMAND
61 } throttleStatusType_e
;
72 } airmodeHandlingType_e
;
75 ROL_LO
= (1 << (2 * ROLL
)),
76 ROL_CE
= (3 << (2 * ROLL
)),
77 ROL_HI
= (2 << (2 * ROLL
)),
79 PIT_LO
= (1 << (2 * PITCH
)),
80 PIT_CE
= (3 << (2 * PITCH
)),
81 PIT_HI
= (2 << (2 * PITCH
)),
83 YAW_LO
= (1 << (2 * YAW
)),
84 YAW_CE
= (3 << (2 * YAW
)),
85 YAW_HI
= (2 << (2 * YAW
)),
87 THR_LO
= (1 << (2 * THROTTLE
)),
88 THR_CE
= (3 << (2 * THROTTLE
)),
89 THR_HI
= (2 << (2 * THROTTLE
))
92 extern int16_t rcCommand
[4];
94 typedef struct rcControlsConfig_s
{
95 uint8_t deadband
; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero.
96 uint8_t yaw_deadband
; // introduce a deadband around the stick center for yaw axis. Must be greater than zero.
97 uint8_t pos_hold_deadband
; // Deadband for position hold
98 uint8_t alt_hold_deadband
; // Defines the neutral zone of throttle stick during altitude hold
99 uint16_t mid_throttle_deadband
; // default throttle deadband from MIDRC
100 uint8_t airmodeHandlingType
; // Defaults to ANTI_WINDUP triggered at sticks centered
101 uint16_t airmodeThrottleThreshold
; // Throttle threshold for airmode initial activation
102 } rcControlsConfig_t
;
104 PG_DECLARE(rcControlsConfig_t
, rcControlsConfig
);
106 typedef struct armingConfig_s
{
107 bool fixed_wing_auto_arm
; // Auto-arm fixed wing aircraft on throttle up and never disarm
108 bool disarm_always
; // Disarm motors regardless of throttle value
109 uint16_t switchDisarmDelayMs
; // additional delay between ARM box going off and actual disarm
110 uint16_t prearmTimeoutMs
; // duration for which Prearm being activated is valid. after this, Prearm needs to be reset. 0 means Prearm does not timeout.
113 PG_DECLARE(armingConfig_t
, armingConfig
);
115 stickPositions_e
getRcStickPositions(void);
116 bool checkStickPosition(stickPositions_e stickPos
);
118 bool areSticksInApModePosition(uint16_t ap_mode
);
119 bool areSticksDeflected(void);
120 bool isRollPitchStickDeflected(uint8_t deadband
);
121 throttleStatus_e
calculateThrottleStatus(throttleStatusType_e type
);
122 int16_t throttleStickMixedValue(void);
123 rollPitchStatus_e
calculateRollPitchCenterStatus(void);
124 void processRcStickPositions(bool isThrottleLow
);
125 bool throttleStickIsLow(void);
127 int32_t getRcStickDeflection(int32_t axis
);