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 // FIXME some of these are flight modes, some of these are general status indicators
23 WAS_EVER_ARMED
= (1 << 3),
25 ARMING_DISABLED_FAILSAFE_SYSTEM
= (1 << 7),
26 ARMING_DISABLED_NOT_LEVEL
= (1 << 8),
27 ARMING_DISABLED_SENSORS_CALIBRATING
= (1 << 9),
28 ARMING_DISABLED_SYSTEM_OVERLOADED
= (1 << 10),
29 ARMING_DISABLED_NAVIGATION_UNSAFE
= (1 << 11),
30 ARMING_DISABLED_COMPASS_NOT_CALIBRATED
= (1 << 12),
31 ARMING_DISABLED_ACCELEROMETER_NOT_CALIBRATED
= (1 << 13),
32 ARMING_DISABLED_ARM_SWITCH
= (1 << 14),
33 ARMING_DISABLED_HARDWARE_FAILURE
= (1 << 15),
34 ARMING_DISABLED_BOXFAILSAFE
= (1 << 16),
35 ARMING_DISABLED_BOXKILLSWITCH
= (1 << 17),
36 ARMING_DISABLED_RC_LINK
= (1 << 18),
37 ARMING_DISABLED_THROTTLE
= (1 << 19),
38 ARMING_DISABLED_CLI
= (1 << 20),
39 ARMING_DISABLED_CMS_MENU
= (1 << 21),
40 ARMING_DISABLED_OSD_MENU
= (1 << 22),
41 ARMING_DISABLED_ROLLPITCH_NOT_CENTERED
= (1 << 23),
42 ARMING_DISABLED_SERVO_AUTOTRIM
= (1 << 24),
43 ARMING_DISABLED_OOM
= (1 << 25),
44 ARMING_DISABLED_INVALID_SETTING
= (1 << 26),
45 ARMING_DISABLED_PWM_OUTPUT_ERROR
= (1 << 27),
46 ARMING_DISABLED_NO_PREARM
= (1 << 28),
47 ARMING_DISABLED_DSHOT_BEEPER
= (1 << 29),
48 ARMING_DISABLED_LANDING_DETECTED
= (1 << 30),
50 ARMING_DISABLED_ALL_FLAGS
= (ARMING_DISABLED_FAILSAFE_SYSTEM
| ARMING_DISABLED_NOT_LEVEL
| ARMING_DISABLED_SENSORS_CALIBRATING
|
51 ARMING_DISABLED_SYSTEM_OVERLOADED
| ARMING_DISABLED_NAVIGATION_UNSAFE
|
52 ARMING_DISABLED_COMPASS_NOT_CALIBRATED
| ARMING_DISABLED_ACCELEROMETER_NOT_CALIBRATED
|
53 ARMING_DISABLED_ARM_SWITCH
| ARMING_DISABLED_HARDWARE_FAILURE
| ARMING_DISABLED_BOXFAILSAFE
|
54 ARMING_DISABLED_BOXKILLSWITCH
| ARMING_DISABLED_RC_LINK
| ARMING_DISABLED_THROTTLE
| ARMING_DISABLED_CLI
|
55 ARMING_DISABLED_CMS_MENU
| ARMING_DISABLED_OSD_MENU
| ARMING_DISABLED_ROLLPITCH_NOT_CENTERED
|
56 ARMING_DISABLED_SERVO_AUTOTRIM
| ARMING_DISABLED_OOM
| ARMING_DISABLED_INVALID_SETTING
|
57 ARMING_DISABLED_PWM_OUTPUT_ERROR
| ARMING_DISABLED_NO_PREARM
| ARMING_DISABLED_DSHOT_BEEPER
|
58 ARMING_DISABLED_LANDING_DETECTED
),
61 // Arming blockers that can be overriden by emergency arming.
62 // Keep in mind that this feature is intended to allow arming in
63 // situations where we might just need the motors to spin so the
64 // aircraft can move (even unpredictably) and get unstuck (e.g.
65 // crashed into a high tree).
66 #define ARMING_DISABLED_EMERGENCY_OVERRIDE (ARMING_DISABLED_NOT_LEVEL \
67 | ARMING_DISABLED_NAVIGATION_UNSAFE \
68 | ARMING_DISABLED_COMPASS_NOT_CALIBRATED \
69 | ARMING_DISABLED_ACCELEROMETER_NOT_CALIBRATED \
70 | ARMING_DISABLED_ARM_SWITCH \
71 | ARMING_DISABLED_HARDWARE_FAILURE)
74 extern uint32_t armingFlags
;
76 extern const char *armingDisableFlagNames
[];
78 #define isArmingDisabled() (armingFlags & (ARMING_DISABLED_ALL_FLAGS))
79 #define DISABLE_ARMING_FLAG(mask) (armingFlags &= ~(mask))
80 #define ENABLE_ARMING_FLAG(mask) (armingFlags |= (mask))
81 #define ARMING_FLAG(mask) (armingFlags & (mask))
83 // Returns the 1st flag from ARMING_DISABLED_ALL_FLAGS which is
84 // preventing arming, or zero if arming is not disabled.
85 armingFlag_e
isArmingDisabledReason(void);
88 ANGLE_MODE
= (1 << 0),
89 HORIZON_MODE
= (1 << 1),
90 HEADING_MODE
= (1 << 2),
91 NAV_ALTHOLD_MODE
= (1 << 3), // old BARO
92 NAV_RTH_MODE
= (1 << 4), // old GPS_HOME
93 NAV_POSHOLD_MODE
= (1 << 5), // old GPS_HOLD
94 HEADFREE_MODE
= (1 << 6),
95 NAV_LAUNCH_MODE
= (1 << 7),
96 MANUAL_MODE
= (1 << 8),
97 FAILSAFE_MODE
= (1 << 9),
98 AUTO_TUNE
= (1 << 10), // old G-Tune
99 NAV_WP_MODE
= (1 << 11),
100 NAV_COURSE_HOLD_MODE
= (1 << 12),
101 FLAPERON
= (1 << 13),
102 TURN_ASSISTANT
= (1 << 14),
103 TURTLE_MODE
= (1 << 15),
104 SOARING_MODE
= (1 << 16),
107 extern uint32_t flightModeFlags
;
109 #define DISABLE_FLIGHT_MODE(mask) disableFlightMode(mask)
110 #define ENABLE_FLIGHT_MODE(mask) enableFlightMode(mask)
111 #define FLIGHT_MODE(mask) (flightModeFlags & (mask))
114 GPS_FIX_HOME
= (1 << 0),
116 CALIBRATE_MAG
= (1 << 2),
117 SMALL_ANGLE
= (1 << 3),
118 FIXED_WING_LEGACY
= (1 << 4), // No new code should use this state. Use AIRPLANE, MULTIROTOR, ROVER, BOAT, ALTITUDE_CONTROL and MOVE_FORWARD_ONLY states
119 ANTI_WINDUP
= (1 << 5),
120 FLAPERON_AVAILABLE
= (1 << 6),
121 NAV_MOTOR_STOP_OR_IDLE
= (1 << 7), // navigation requests MOTOR_STOP or motor idle regardless of throttle stick, will only activate if MOTOR_STOP feature is available
122 COMPASS_CALIBRATED
= (1 << 8),
123 ACCELEROMETER_CALIBRATED
= (1 << 9),
124 NAV_CRUISE_BRAKING
= (1 << 11),
125 NAV_CRUISE_BRAKING_BOOST
= (1 << 12),
126 NAV_CRUISE_BRAKING_LOCKED
= (1 << 13),
127 NAV_EXTRA_ARMING_SAFETY_BYPASSED
= (1 << 14), // nav_extra_arming_safey was bypassed. Keep it until power cycle.
128 AIRMODE_ACTIVE
= (1 << 15),
129 ESC_SENSOR_ENABLED
= (1 << 16),
130 AIRPLANE
= (1 << 17),
131 MULTIROTOR
= (1 << 18),
134 ALTITUDE_CONTROL
= (1 << 21), //It means it can fly
135 MOVE_FORWARD_ONLY
= (1 << 22),
136 SET_REVERSIBLE_MOTORS_FORWARD
= (1 << 23),
137 FW_HEADING_USE_YAW
= (1 << 24),
138 ANTI_WINDUP_DEACTIVATED
= (1 << 25),
139 LANDING_DETECTED
= (1 << 26),
142 #define DISABLE_STATE(mask) (stateFlags &= ~(mask))
143 #define ENABLE_STATE(mask) (stateFlags |= (mask))
144 #define STATE(mask) (stateFlags & (mask))
146 extern uint32_t stateFlags
;
163 } flightModeForTelemetry_e
;
165 flightModeForTelemetry_e
getFlightModeForTelemetry(void);
167 uint32_t enableFlightMode(flightModeFlags_e mask
);
168 uint32_t disableFlightMode(flightModeFlags_e mask
);
170 bool sensors(uint32_t mask
);
171 void sensorsSet(uint32_t mask
);
172 void sensorsClear(uint32_t mask
);
173 uint32_t sensorsMask(void);