mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 11:29:56 +03:00
Added EDGE switch to Logical Conditions
This commit is contained in:
parent
7e51f1ff5d
commit
1ca3527f92
3 changed files with 25 additions and 5 deletions
|
@ -80,6 +80,8 @@ IPF can be edited using INAV Configurator user interface, of via CLI
|
|||
| 44 | MAX | Finds the highest value of `Operand A` and `Operand B` |
|
||||
| 45 | FLIGHT_AXIS_ANGLE_OVERRIDE | Sets the target attitude angle for axis. In other words, when active, it enforces Angle mode (Heading Hold for Yaw) on this axis (Angle mode does not have to be active). `Operand A` defines the axis: `0` - Roll, `1` - Pitch, `2` - Yaw. `Operand B` defines the angle in degrees |
|
||||
| 46 | FLIGHT_AXIS_RATE_OVERRIDE | Sets the target rate (rotation speed) for axis. `Operand A` defines the axis: `0` - Roll, `1` - Pitch, `2` - Yaw. `Operand B` defines the rate in degrees per second |
|
||||
| 47 | EDGE | `Operand A` is activation operator [`boolean`], `Operand B` is the time for the edge to stay active [ms]. After activation, operator will return `true` until the time in Operand B is reached |
|
||||
|
||||
### Operands
|
||||
|
||||
| Operand Type | Name | Notes |
|
||||
|
|
|
@ -90,7 +90,7 @@ static int logicConditionCompute(
|
|||
logicOperation_e operation,
|
||||
int32_t operandA,
|
||||
int32_t operandB,
|
||||
timeMs_t *timeout
|
||||
uint8_t lcIndex
|
||||
) {
|
||||
int temporaryValue;
|
||||
vtxDeviceCapability_t vtxDeviceCapability;
|
||||
|
@ -164,9 +164,26 @@ static int logicConditionCompute(
|
|||
break;
|
||||
|
||||
case LOGIC_CONDITION_EDGE:
|
||||
if (operandA && timeout == 0) {
|
||||
|
||||
if (operandA && logicConditionStates[lcIndex].timeout == 0 && !(logicConditionStates[lcIndex].flags & LOGIC_CONDITION_FLAG_EDGE_SATISFIED)) {
|
||||
if (operandB < 100) {
|
||||
logicConditionStates[lcIndex].timeout = millis() + 100;
|
||||
} else {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandB;
|
||||
}
|
||||
logicConditionStates[lcIndex].flags |= LOGIC_CONDITION_FLAG_EDGE_SATISFIED;
|
||||
return true;
|
||||
} else if (logicConditionStates[lcIndex].timeout > 0) {
|
||||
if (logicConditionStates[lcIndex].timeout < millis()) {
|
||||
logicConditionStates[lcIndex].timeout = 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!operandA) {
|
||||
logicConditionStates[lcIndex].flags &= ~LOGIC_CONDITION_FLAG_EDGE_SATISFIED;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_GVAR_SET:
|
||||
|
@ -433,7 +450,7 @@ void logicConditionProcess(uint8_t i) {
|
|||
logicConditions(i)->operation,
|
||||
operandAValue,
|
||||
operandBValue,
|
||||
&logicConditionStates[i].timeout,
|
||||
i
|
||||
);
|
||||
|
||||
logicConditionStates[i].value = newValue;
|
||||
|
|
|
@ -167,7 +167,8 @@ typedef enum {
|
|||
} logicConditionsGlobalFlags_t;
|
||||
|
||||
typedef enum {
|
||||
LOGIC_CONDITION_FLAG_LATCH = 1 << 0,
|
||||
LOGIC_CONDITION_FLAG_LATCH = 1 << 0,
|
||||
LOGIC_CONDITION_FLAG_EDGE_SATISFIED = 1 << 1,
|
||||
} logicConditionFlags_e;
|
||||
|
||||
typedef struct logicOperand_s {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue