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/>.
23 #include "fc/runtime_config.h"
24 #include "io/beeper.h"
26 uint8_t armingFlags
= 0;
27 uint8_t stateFlags
= 0;
28 uint16_t flightModeFlags
= 0;
30 static uint32_t enabledSensors
= 0;
32 static armingDisableFlags_e armingDisableFlags
= 0;
34 void setArmingDisabled(armingDisableFlags_e flag
)
36 armingDisableFlags
= armingDisableFlags
| flag
;
39 void unsetArmingDisabled(armingDisableFlags_e flag
)
41 armingDisableFlags
= armingDisableFlags
& ~flag
;
44 bool isArmingDisabled()
46 return armingDisableFlags
;
49 armingDisableFlags_e
getArmingDisableFlags(void)
51 return armingDisableFlags
;
55 * Enables the given flight mode. A beep is sounded if the flight mode
56 * has changed. Returns the new 'flightModeFlags' value.
58 uint16_t enableFlightMode(flightModeFlags_e mask
)
60 uint16_t oldVal
= flightModeFlags
;
62 flightModeFlags
|= (mask
);
63 if (flightModeFlags
!= oldVal
)
64 beeperConfirmationBeeps(1);
65 return flightModeFlags
;
69 * Disables the given flight mode. A beep is sounded if the flight mode
70 * has changed. Returns the new 'flightModeFlags' value.
72 uint16_t disableFlightMode(flightModeFlags_e mask
)
74 uint16_t oldVal
= flightModeFlags
;
76 flightModeFlags
&= ~(mask
);
77 if (flightModeFlags
!= oldVal
)
78 beeperConfirmationBeeps(1);
79 return flightModeFlags
;
82 bool sensors(uint32_t mask
)
84 return enabledSensors
& mask
;
87 void sensorsSet(uint32_t mask
)
89 enabledSensors
|= mask
;
92 void sensorsClear(uint32_t mask
)
94 enabledSensors
&= ~(mask
);
97 uint32_t sensorsMask(void)
99 return enabledSensors
;