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/>.
26 #include "fc/runtime_config.h"
27 #include "io/beeper.h"
29 uint8_t armingFlags
= 0;
30 uint8_t stateFlags
= 0;
31 uint16_t flightModeFlags
= 0;
33 static uint32_t enabledSensors
= 0;
35 // Must be no longer than OSD_WARNINGS_MAX_SIZE (11) to be displayed fully in OSD
36 const char *armingDisableFlagNames
[]= {
65 static armingDisableFlags_e armingDisableFlags
= 0;
67 void setArmingDisabled(armingDisableFlags_e flag
)
69 armingDisableFlags
= armingDisableFlags
| flag
;
72 void unsetArmingDisabled(armingDisableFlags_e flag
)
74 armingDisableFlags
= armingDisableFlags
& ~flag
;
77 bool isArmingDisabled(void)
79 return armingDisableFlags
;
82 armingDisableFlags_e
getArmingDisableFlags(void)
84 return armingDisableFlags
;
88 * Enables the given flight mode. A beep is sounded if the flight mode
89 * has changed. Returns the new 'flightModeFlags' value.
91 uint16_t enableFlightMode(flightModeFlags_e mask
)
93 uint16_t oldVal
= flightModeFlags
;
95 flightModeFlags
|= (mask
);
96 if (flightModeFlags
!= oldVal
)
97 beeperConfirmationBeeps(1);
98 return flightModeFlags
;
102 * Disables the given flight mode. A beep is sounded if the flight mode
103 * has changed. Returns the new 'flightModeFlags' value.
105 uint16_t disableFlightMode(flightModeFlags_e mask
)
107 uint16_t oldVal
= flightModeFlags
;
109 flightModeFlags
&= ~(mask
);
110 if (flightModeFlags
!= oldVal
)
111 beeperConfirmationBeeps(1);
112 return flightModeFlags
;
115 bool sensors(uint32_t mask
)
117 return enabledSensors
& mask
;
120 void sensorsSet(uint32_t mask
)
122 enabledSensors
|= mask
;
125 void sensorsClear(uint32_t mask
)
127 enabledSensors
&= ~(mask
);
130 uint32_t sensorsMask(void)
132 return enabledSensors
;