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
{
69 THROTTLE_STATUS_TYPE_RC
= 0,
70 THROTTLE_STATUS_TYPE_COMMAND
71 } throttleStatusType_e
;
82 } airmodeHandlingType_e
;
85 ROL_LO
= (1 << (2 * ROLL
)),
86 ROL_CE
= (3 << (2 * ROLL
)),
87 ROL_HI
= (2 << (2 * ROLL
)),
89 PIT_LO
= (1 << (2 * PITCH
)),
90 PIT_CE
= (3 << (2 * PITCH
)),
91 PIT_HI
= (2 << (2 * PITCH
)),
93 YAW_LO
= (1 << (2 * YAW
)),
94 YAW_CE
= (3 << (2 * YAW
)),
95 YAW_HI
= (2 << (2 * YAW
)),
97 THR_LO
= (1 << (2 * THROTTLE
)),
98 THR_CE
= (3 << (2 * THROTTLE
)),
99 THR_HI
= (2 << (2 * THROTTLE
))
102 extern int16_t rcCommand
[4];
104 typedef struct rcControlsConfig_s
{
105 uint8_t deadband
; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero.
106 uint8_t yaw_deadband
; // introduce a deadband around the stick center for yaw axis. Must be greater than zero.
107 uint8_t pos_hold_deadband
; // Deadband for position hold
108 uint8_t alt_hold_deadband
; // Defines the neutral zone of throttle stick during altitude hold
109 uint16_t mid_throttle_deadband
; // default throttle deadband from MIDRC
110 uint8_t airmodeHandlingType
; // Defaults to ANTI_WINDUP triggered at sticks centered
111 uint16_t airmodeThrottleThreshold
; // Throttle threshold for airmode initial activation
112 } rcControlsConfig_t
;
114 PG_DECLARE(rcControlsConfig_t
, rcControlsConfig
);
116 typedef struct armingConfig_s
{
117 bool fixed_wing_auto_arm
; // Auto-arm fixed wing aircraft on throttle up and never disarm
118 bool disarm_always
; // Disarm motors regardless of throttle value
119 uint16_t switchDisarmDelayMs
; // additional delay between ARM box going off and actual disarm
120 uint16_t prearmTimeoutMs
; // duration for which Prearm being activated is valid. after this, Prearm needs to be reset. 0 means Prearm does not timeout.
123 PG_DECLARE(armingConfig_t
, armingConfig
);
125 stickPositions_e
getRcStickPositions(void);
126 bool checkStickPosition(stickPositions_e stickPos
);
128 bool areSticksInApModePosition(uint16_t ap_mode
);
129 bool areSticksDeflected(void);
130 bool isRollPitchStickDeflected(uint8_t deadband
);
131 throttleStatus_e
calculateThrottleStatus(throttleStatusType_e type
);
132 int16_t throttleStickMixedValue(void);
133 rollPitchStatus_e
calculateRollPitchCenterStatus(void);
134 void processRcStickPositions(bool isThrottleLow
);
135 bool throttleStickIsLow(void);
137 int32_t getRcStickDeflection(int32_t axis
);