[FLYWOOF411] add board documentation
[inav/snaewe.git] / src / main / programming / global_functions.h
blobadcaec001bd493e84222861f0bd44010990954cc
1 /*
2 * This file is part of INAV Project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/.
8 * Alternatively, the contents of this file may be used under the terms
9 * of the GNU General Public License Version 3, as described below:
11 * This file is free software: you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by the
13 * Free Software Foundation, either version 3 of the License, or (at your
14 * option) any later version.
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see http://www.gnu.org/licenses/.
24 #pragma once
26 #include "config/parameter_group.h"
27 #include "programming/logic_condition.h"
29 #define MAX_GLOBAL_FUNCTIONS 8
31 typedef enum {
32 GLOBAL_FUNCTION_ACTION_OVERRIDE_ARMING_SAFETY = 0, // 0
33 GLOBAL_FUNCTION_ACTION_OVERRIDE_THROTTLE_SCALE, // 1
34 GLOBAL_FUNCTION_ACTION_SWAP_ROLL_YAW, // 2
35 GLOBAL_FUNCTION_ACTION_SET_VTX_POWER_LEVEL, // 3
36 GLOBAL_FUNCTION_ACTION_INVERT_ROLL, // 4
37 GLOBAL_FUNCTION_ACTION_INVERT_PITCH, // 5
38 GLOBAL_FUNCTION_ACTION_INVERT_YAW, // 6
39 GLOBAL_FUNCTION_ACTION_OVERRIDE_THROTTLE, // 7
40 GLOBAL_FUNCTION_ACTION_SET_VTX_BAND, // 8
41 GLOBAL_FUNCTION_ACTION_SET_VTX_CHANNEL, // 9
42 GLOBAL_FUNCTION_ACTION_LAST
43 } globalFunctionActions_e;
45 typedef enum {
46 GLOBAL_FUNCTION_FLAG_OVERRIDE_ARMING_SAFETY = (1 << 0),
47 GLOBAL_FUNCTION_FLAG_OVERRIDE_THROTTLE_SCALE = (1 << 1),
48 GLOBAL_FUNCTION_FLAG_OVERRIDE_SWAP_ROLL_YAW = (1 << 2),
49 GLOBAL_FUNCTION_FLAG_OVERRIDE_INVERT_ROLL = (1 << 3),
50 GLOBAL_FUNCTION_FLAG_OVERRIDE_INVERT_PITCH = (1 << 4),
51 GLOBAL_FUNCTION_FLAG_OVERRIDE_INVERT_YAW = (1 << 5),
52 GLOBAL_FUNCTION_FLAG_OVERRIDE_THROTTLE = (1 << 6),
53 } globalFunctionFlags_t;
55 typedef struct globalFunction_s {
56 uint8_t enabled;
57 int8_t conditionId;
58 uint8_t action;
59 logicOperand_t withValue;
60 uint8_t flags;
61 } globalFunction_t;
63 typedef struct globalFunctionState_s {
64 uint8_t active;
65 int value;
66 uint8_t flags;
67 } globalFunctionState_t;
69 extern uint64_t globalFunctionsFlags;
71 #define GLOBAL_FUNCTION_FLAG_DISABLE(mask) (globalFunctionsFlags &= ~(mask))
72 #define GLOBAL_FUNCTION_FLAG_ENABLE(mask) (globalFunctionsFlags |= (mask))
73 #define GLOBAL_FUNCTION_FLAG(mask) (globalFunctionsFlags & (mask))
75 PG_DECLARE_ARRAY(globalFunction_t, MAX_GLOBAL_FUNCTIONS, globalFunctions);
76 extern int globalFunctionValues[GLOBAL_FUNCTION_ACTION_LAST];
78 void globalFunctionsUpdateTask(timeUs_t currentTimeUs);
79 float getThrottleScale(float globalThrottleScale);
80 int16_t getRcCommandOverride(int16_t command[], uint8_t axis);