Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / fc / runtime_config.c
blob290482454dbbe38d89fa1c6948fe5878147a7d6d
1 /*
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)
8 * any later version.
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/>.
21 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
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[]= {
37 "NOGYRO",
38 "FAILSAFE",
39 "RXLOSS",
40 "BADRX",
41 "BOXFAILSAFE",
42 "RUNAWAY",
43 "CRASH",
44 "THROTTLE",
45 "ANGLE",
46 "BOOTGRACE",
47 "NOPREARM",
48 "LOAD",
49 "CALIB",
50 "CLI",
51 "CMS",
52 "BST",
53 "MSP",
54 "PARALYZE",
55 "GPS",
56 "RESCUE_SW",
57 "RPMFILTER",
58 "REBOOT_REQD",
59 "DSHOT_BBANG",
60 "NO_ACC_CAL",
61 "MOTOR_PROTO",
62 "ARMSWITCH",
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;
87 /**
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;