1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 16:25:26 +03:00

move the modulus to the last entry

This commit is contained in:
Mingchen Zhang 2021-03-12 02:14:22 +00:00
parent 2eecf30603
commit cce8345d90
3 changed files with 32 additions and 32 deletions

View file

@ -51,7 +51,6 @@ IPF can be edited using INAV Configurator user interface, of via CLI
| 15 | SUB | Substract `Operand B` from `Operand A` and returns the result | | 15 | SUB | Substract `Operand B` from `Operand A` and returns the result |
| 16 | MUL | Multiply `Operand A` by `Operand B` and returns the result | | 16 | MUL | Multiply `Operand A` by `Operand B` and returns the result |
| 17 | DIV | Divide `Operand A` by `Operand B` and returns the result | | 17 | DIV | Divide `Operand A` by `Operand B` and returns the result |
| 17 | MOD | Divide `Operand A` by `Operand B` and returns the remainder |
| 18 | GVAR SET | Store value from `Operand B` into the Global Variable addressed by `Operand B`. Bear in mind, that operand `Global Variable` means: Value stored in Global Variable of an index! To store in GVAR 1 use `Value 1` not `Global Variable 1` | | 18 | GVAR SET | Store value from `Operand B` into the Global Variable addressed by `Operand B`. Bear in mind, that operand `Global Variable` means: Value stored in Global Variable of an index! To store in GVAR 1 use `Value 1` not `Global Variable 1` |
| 19 | GVAR INC | Increase the GVAR indexed by `Operand A` with value from `Operand B` | | 19 | GVAR INC | Increase the GVAR indexed by `Operand A` with value from `Operand B` |
| 20 | GVAR DEC | Decrease the GVAR indexed by `Operand A` with value from `Operand B` | | 20 | GVAR DEC | Decrease the GVAR indexed by `Operand A` with value from `Operand B` |
@ -74,6 +73,7 @@ IPF can be edited using INAV Configurator user interface, of via CLI
| 37 | MAP_OUTPUT | Scales `Operand A` from [`0` : `1000`] to [`0` : `Operand B`]. Note: input will be constrained and then scaled | | 37 | MAP_OUTPUT | Scales `Operand A` from [`0` : `1000`] to [`0` : `Operand B`]. Note: input will be constrained and then scaled |
| 38 | RC_CHANNEL_OVERRIDE | Overrides channel set by `Operand A` to value of `Operand B` | | 38 | RC_CHANNEL_OVERRIDE | Overrides channel set by `Operand A` to value of `Operand B` |
| 39 | SET_HEADING_TARGET | Sets heading-hold target to `Operand A`, in degrees. Value wraps-around. | | 39 | SET_HEADING_TARGET | Sets heading-hold target to `Operand A`, in degrees. Value wraps-around. |
| 40 | MOD | Divide `Operand A` by `Operand B` and returns the remainder |
### Operands ### Operands

View file

@ -193,14 +193,6 @@ static int logicConditionCompute(
return operandA; return operandA;
} }
break; break;
case LOGIC_CONDITION_MODULUS:
if (operandB != 0) {
return constrain(operandA % operandB, INT16_MIN, INT16_MAX);
} else {
return operandA;
}
break;
case LOGIC_CONDITION_OVERRIDE_ARMING_SAFETY: case LOGIC_CONDITION_OVERRIDE_ARMING_SAFETY:
LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_ARMING_SAFETY); LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_ARMING_SAFETY);
@ -332,6 +324,14 @@ static int logicConditionCompute(
return temporaryValue; return temporaryValue;
break; break;
case LOGIC_CONDITION_MODULUS:
if (operandB != 0) {
return constrain(operandA % operandB, INT16_MIN, INT16_MAX);
} else {
return operandA;
}
break;
default: default:
return false; return false;
break; break;

View file

@ -47,29 +47,29 @@ typedef enum {
LOGIC_CONDITION_SUB = 15, LOGIC_CONDITION_SUB = 15,
LOGIC_CONDITION_MUL = 16, LOGIC_CONDITION_MUL = 16,
LOGIC_CONDITION_DIV = 17, LOGIC_CONDITION_DIV = 17,
LOGIC_CONDITION_MODULUS = 18, LOGIC_CONDITION_GVAR_SET = 18,
LOGIC_CONDITION_GVAR_SET = 19, LOGIC_CONDITION_GVAR_INC = 19,
LOGIC_CONDITION_GVAR_INC = 20, LOGIC_CONDITION_GVAR_DEC = 20,
LOGIC_CONDITION_GVAR_DEC = 21, LOGIC_CONDITION_PORT_SET = 21,
LOGIC_CONDITION_PORT_SET = 22, LOGIC_CONDITION_OVERRIDE_ARMING_SAFETY = 22,
LOGIC_CONDITION_OVERRIDE_ARMING_SAFETY = 23, LOGIC_CONDITION_OVERRIDE_THROTTLE_SCALE = 23,
LOGIC_CONDITION_OVERRIDE_THROTTLE_SCALE = 24, LOGIC_CONDITION_SWAP_ROLL_YAW = 24,
LOGIC_CONDITION_SWAP_ROLL_YAW = 25, LOGIC_CONDITION_SET_VTX_POWER_LEVEL = 25,
LOGIC_CONDITION_SET_VTX_POWER_LEVEL = 26, LOGIC_CONDITION_INVERT_ROLL = 26,
LOGIC_CONDITION_INVERT_ROLL = 27, LOGIC_CONDITION_INVERT_PITCH = 27,
LOGIC_CONDITION_INVERT_PITCH = 28, LOGIC_CONDITION_INVERT_YAW = 28,
LOGIC_CONDITION_INVERT_YAW = 29, LOGIC_CONDITION_OVERRIDE_THROTTLE = 29,
LOGIC_CONDITION_OVERRIDE_THROTTLE = 30, LOGIC_CONDITION_SET_VTX_BAND = 30,
LOGIC_CONDITION_SET_VTX_BAND = 31, LOGIC_CONDITION_SET_VTX_CHANNEL = 31,
LOGIC_CONDITION_SET_VTX_CHANNEL = 32, LOGIC_CONDITION_SET_OSD_LAYOUT = 32,
LOGIC_CONDITION_SET_OSD_LAYOUT = 33, LOGIC_CONDITION_SIN = 33,
LOGIC_CONDITION_SIN = 34, LOGIC_CONDITION_COS = 34,
LOGIC_CONDITION_COS = 35, LOGIC_CONDITION_TAN = 35,
LOGIC_CONDITION_TAN = 36, LOGIC_CONDITION_MAP_INPUT = 36,
LOGIC_CONDITION_MAP_INPUT = 37, LOGIC_CONDITION_MAP_OUTPUT = 37,
LOGIC_CONDITION_MAP_OUTPUT = 38, LOGIC_CONDITION_RC_CHANNEL_OVERRIDE = 38,
LOGIC_CONDITION_RC_CHANNEL_OVERRIDE = 39, LOGIC_CONDITION_SET_HEADING_TARGET = 39,
LOGIC_CONDITION_SET_HEADING_TARGET = 40, LOGIC_CONDITION_MODULUS = 40,
LOGIC_CONDITION_LAST = 41, LOGIC_CONDITION_LAST = 41,
} logicOperation_e; } logicOperation_e;