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/>.
27 #define BOXID_NONE 255
42 BOXID_FLIGHTMODE_LAST
= BOXGPSRESCUE
,
44 // When new flight modes are added, the parameter group version for 'modeActivationConditions' in src/main/fc/rc_modes.c has to be incremented to ensure that the RC modes configuration is reset.
80 BOXSTICKCOMMANDDISABLE
,
92 // type to hold enough bits for CHECKBOX_ITEM_COUNT. Struct used for value-like behavior
93 typedef struct boxBitmask_s
{ uint32_t bits
[(CHECKBOX_ITEM_COUNT
+ 31) / 32]; } boxBitmask_t
;
95 #define MAX_MODE_ACTIVATION_CONDITION_COUNT 20
97 #define CHANNEL_RANGE_MIN 900
98 #define CHANNEL_RANGE_MAX 2100
100 #define MODE_STEP_TO_CHANNEL_VALUE(step) (CHANNEL_RANGE_MIN + 25 * step)
101 #define CHANNEL_VALUE_TO_STEP(channelValue) ((constrain(channelValue, CHANNEL_RANGE_MIN, CHANNEL_RANGE_MAX) - CHANNEL_RANGE_MIN) / 25)
103 #define MIN_MODE_RANGE_STEP 0
104 #define MAX_MODE_RANGE_STEP ((CHANNEL_RANGE_MAX - CHANNEL_RANGE_MIN) / 25)
106 // steps are 25 apart
107 // a value of 0 corresponds to a channel value of 900 or less
108 // a value of 48 corresponds to a channel value of 2100 or more
109 // 48 steps between 900 and 2100
110 typedef struct channelRange_s
{
115 typedef struct modeActivationCondition_s
{
117 uint8_t auxChannelIndex
;
118 channelRange_t range
;
119 modeLogic_e modeLogic
;
121 } modeActivationCondition_t
;
123 PG_DECLARE_ARRAY(modeActivationCondition_t
, MAX_MODE_ACTIVATION_CONDITION_COUNT
, modeActivationConditions
);
125 #if defined(USE_CUSTOM_BOX_NAMES)
127 #define MAX_BOX_USER_NAME_LENGTH 16
128 #define BOX_USER_NAME_COUNT 4
129 STATIC_ASSERT(BOXUSER4
+ 1 - BOXUSER1
== BOX_USER_NAME_COUNT
, "Invalid BOX_USER_NAME_COUNT");
130 typedef struct modeActivationConfig_s
{
131 char box_user_names
[BOX_USER_NAME_COUNT
][MAX_BOX_USER_NAME_LENGTH
];
132 } modeActivationConfig_t
;
134 PG_DECLARE(modeActivationConfig_t
, modeActivationConfig
);
137 typedef struct modeActivationProfile_s
{
138 modeActivationCondition_t modeActivationConditions
[MAX_MODE_ACTIVATION_CONDITION_COUNT
];
139 } modeActivationProfile_t
;
141 #define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
143 bool IS_RC_MODE_ACTIVE(boxId_e boxId
);
144 void rcModeUpdate(const boxBitmask_t
*newState
);
146 bool isAirmodeEnabled(void);
148 bool isRangeActive(uint8_t auxChannelIndex
, const channelRange_t
*range
);
149 void updateActivatedModes(void);
150 bool isModeActivationConditionPresent(boxId_e modeId
);
151 bool isModeActivationConditionLinked(boxId_e modeId
);
152 void removeModeActivationCondition(boxId_e modeId
);
153 bool isModeActivationConditionConfigured(const modeActivationCondition_t
*mac
, const modeActivationCondition_t
*emptyMac
);
154 void analyzeModeActivationConditions(void);