mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-15 20:35:29 +03:00
Added some more logic
Added delay, almost equal, and timer. Not yet tested.
This commit is contained in:
parent
1ca3527f92
commit
026e40c297
2 changed files with 48 additions and 6 deletions
|
@ -105,6 +105,11 @@ static int logicConditionCompute(
|
|||
return operandA == operandB;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_APPROX_EQUAL:
|
||||
uint16_t offest = operandA / 100;
|
||||
return ((operandB >= (operandA - offest)) && (operandB <= (operandA + offest)));
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_GREATER_THAN:
|
||||
return operandA > operandB;
|
||||
break;
|
||||
|
@ -164,13 +169,13 @@ static int logicConditionCompute(
|
|||
break;
|
||||
|
||||
case LOGIC_CONDITION_EDGE:
|
||||
if (operandA && logicConditionStates[lcIndex].timeout == 0 && !(logicConditionStates[lcIndex].flags & LOGIC_CONDITION_FLAG_EDGE_SATISFIED)) {
|
||||
if (operandA && logicConditionStates[lcIndex].timeout == 0 && !(logicConditionStates[lcIndex].flags & LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED)) {
|
||||
if (operandB < 100) {
|
||||
logicConditionStates[lcIndex].timeout = millis() + 100;
|
||||
} else {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandB;
|
||||
}
|
||||
logicConditionStates[lcIndex].flags |= LOGIC_CONDITION_FLAG_EDGE_SATISFIED;
|
||||
logicConditionStates[lcIndex].flags |= LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED;
|
||||
return true;
|
||||
} else if (logicConditionStates[lcIndex].timeout > 0) {
|
||||
if (logicConditionStates[lcIndex].timeout < millis()) {
|
||||
|
@ -181,11 +186,44 @@ static int logicConditionCompute(
|
|||
}
|
||||
|
||||
if (!operandA) {
|
||||
logicConditionStates[lcIndex].flags &= ~LOGIC_CONDITION_FLAG_EDGE_SATISFIED;
|
||||
logicConditionStates[lcIndex].flags &= ~LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_DELAY:
|
||||
if (operandA) {
|
||||
if (logicConditionStates[lcIndex].flags & LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED) {
|
||||
return true;
|
||||
} else if (logicConditionStates[lcIndex].timeout > millis()) {
|
||||
logicConditionStates[lcIndex].flags |= LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED;
|
||||
return true;
|
||||
} else if (logicConditionStates[lcIndex].timeout == 0) {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandB;
|
||||
}
|
||||
} else {
|
||||
logicConditionStates[lcIndex].timeout = 0;
|
||||
logicConditionStates[lcIndex].flags &= ~LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED;
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_TIMER:
|
||||
if (logicConditionStates[lcIndex].timeout > millis() && currentVaue) {
|
||||
logicConditionStates[lcIndex].timeout millis() + operandB;
|
||||
return false;
|
||||
} else if ((logicConditionStates[lcIndex].timeout == 0) || (logicConditionStates[lcIndex].timeout > millis() && currentVaue)) {
|
||||
logicConditionStates[lcIndex].timeout millis() + operandA;
|
||||
return true;
|
||||
}
|
||||
return currentVaue;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_DELTA:
|
||||
return false;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_GVAR_SET:
|
||||
gvSet(operandA, operandB);
|
||||
return operandB;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue