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)
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/>.
23 #include "common/time.h"
26 #if defined(USE_GPS) || defined(USE_MAG)
27 extern int16_t magHold
;
30 typedef struct throttleCorrectionConfig_s
{
31 uint16_t throttle_correction_angle
; // the angle when the throttle correction is maximal. in 0.1 degres, ex 225 = 22.5 ,30.0, 450 = 45.0 deg
32 uint8_t throttle_correction_value
; // the correction that will be applied at throttle_correction_angle.
33 } throttleCorrectionConfig_t
;
36 LAUNCH_CONTROL_DISABLED
= 0,
37 LAUNCH_CONTROL_ACTIVE
,
38 LAUNCH_CONTROL_TRIGGERED
,
39 } launchControlState_e
;
42 LAUNCH_CONTROL_MODE_NORMAL
= 0,
43 LAUNCH_CONTROL_MODE_PITCHONLY
,
44 LAUNCH_CONTROL_MODE_FULL
,
45 LAUNCH_CONTROL_MODE_COUNT
// must be the last element
46 } launchControlMode_e
;
49 DISARM_REASON_ARMING_DISABLED
= 0,
50 DISARM_REASON_FAILSAFE
= 1,
51 DISARM_REASON_THROTTLE_TIMEOUT
= 2,
52 DISARM_REASON_STICKS
= 3,
53 DISARM_REASON_SWITCH
= 4,
54 DISARM_REASON_CRASH_PROTECTION
= 5,
55 DISARM_REASON_RUNAWAY_TAKEOFF
= 6,
56 DISARM_REASON_GPS_RESCUE
= 7,
57 DISARM_REASON_SERIAL_COMMAND
= 8,
59 DISARM_REASON_SYSTEM
= 255,
61 } flightLogDisarmReason_e
;
63 #ifdef USE_LAUNCH_CONTROL
64 #define LAUNCH_CONTROL_THROTTLE_TRIGGER_MAX 90
65 extern const char * const osdLaunchControlModeNames
[LAUNCH_CONTROL_MODE_COUNT
];
68 PG_DECLARE(throttleCorrectionConfig_t
, throttleCorrectionConfig
);
70 union rollAndPitchTrims_u
;
71 void handleInflightCalibrationStickPosition(void);
73 void resetArmingDisabled(void);
75 void disarm(flightLogDisarmReason_e reason
);
78 bool processRx(timeUs_t currentTimeUs
);
79 void processRxModes(timeUs_t currentTimeUs
);
80 void updateArmingStatus(void);
82 void taskGyroSample(timeUs_t currentTimeUs
);
83 bool gyroFilterReady(void);
84 bool pidLoopReady(void);
85 void taskFiltering(timeUs_t currentTimeUs
);
86 void taskMainPidLoop(timeUs_t currentTimeUs
);
88 bool isFlipOverAfterCrashActive(void);
89 int8_t calculateThrottlePercent(void);
90 uint8_t calculateThrottlePercentAbs(void);
91 bool areSticksActive(uint8_t stickPercentLimit
);
92 void runawayTakeoffTemporaryDisable(uint8_t disableFlag
);
93 bool isAirmodeActivated();
94 timeUs_t
getLastDisarmTimeUs(void);
96 void resetTryingToArm();
98 void subTaskTelemetryPollSensors(timeUs_t currentTimeUs
);
100 bool isLaunchControlActive(void);