mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 11:29:56 +03:00
Merge branch 'master' into MrD_Enhance-programming-options-for-waypoint-missions
This commit is contained in:
commit
ba8da95562
61 changed files with 1877 additions and 357 deletions
|
@ -86,10 +86,11 @@ void pgResetFn_logicConditions(logicCondition_t *instance)
|
|||
logicConditionState_t logicConditionStates[MAX_LOGIC_CONDITIONS];
|
||||
|
||||
static int logicConditionCompute(
|
||||
int32_t currentVaue,
|
||||
int32_t currentValue,
|
||||
logicOperation_e operation,
|
||||
int32_t operandA,
|
||||
int32_t operandB
|
||||
int32_t operandB,
|
||||
uint8_t lcIndex
|
||||
) {
|
||||
int temporaryValue;
|
||||
vtxDeviceCapability_t vtxDeviceCapability;
|
||||
|
@ -104,6 +105,13 @@ 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;
|
||||
|
@ -159,7 +167,67 @@ static int logicConditionCompute(
|
|||
}
|
||||
|
||||
//When both operands are not met, keep current value
|
||||
return currentVaue;
|
||||
return currentValue;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_EDGE:
|
||||
if (operandA && logicConditionStates[lcIndex].timeout == 0 && !(logicConditionStates[lcIndex].flags & LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED)) {
|
||||
if (operandB < 100) {
|
||||
logicConditionStates[lcIndex].timeout = millis();
|
||||
} else {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandB;
|
||||
}
|
||||
logicConditionStates[lcIndex].flags |= LOGIC_CONDITION_FLAG_TIMEOUT_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_TIMEOUT_SATISFIED;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_DELAY:
|
||||
if (operandA) {
|
||||
if (logicConditionStates[lcIndex].timeout == 0) {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandB;
|
||||
} else if (millis() > logicConditionStates[lcIndex].timeout ) {
|
||||
logicConditionStates[lcIndex].flags |= LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED;
|
||||
return true;
|
||||
} else if (logicConditionStates[lcIndex].flags & LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
logicConditionStates[lcIndex].timeout = 0;
|
||||
logicConditionStates[lcIndex].flags &= ~LOGIC_CONDITION_FLAG_TIMEOUT_SATISFIED;
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_TIMER:
|
||||
if ((logicConditionStates[lcIndex].timeout == 0) || (millis() > logicConditionStates[lcIndex].timeout && !currentValue)) {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandA;
|
||||
return true;
|
||||
} else if (millis() > logicConditionStates[lcIndex].timeout && currentValue) {
|
||||
logicConditionStates[lcIndex].timeout = millis() + operandB;
|
||||
return false;
|
||||
}
|
||||
return currentValue;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_DELTA:
|
||||
{
|
||||
int difference = logicConditionStates[lcIndex].lastValue - operandA;
|
||||
logicConditionStates[lcIndex].lastValue = operandA;
|
||||
return ABS(difference) >= operandB;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_GVAR_SET:
|
||||
|
@ -425,7 +493,8 @@ void logicConditionProcess(uint8_t i) {
|
|||
logicConditionStates[i].value,
|
||||
logicConditions(i)->operation,
|
||||
operandAValue,
|
||||
operandBValue
|
||||
operandBValue,
|
||||
i
|
||||
);
|
||||
|
||||
logicConditionStates[i].value = newValue;
|
||||
|
@ -876,7 +945,9 @@ void logicConditionUpdateTask(timeUs_t currentTimeUs) {
|
|||
void logicConditionReset(void) {
|
||||
for (uint8_t i = 0; i < MAX_LOGIC_CONDITIONS; i++) {
|
||||
logicConditionStates[i].value = 0;
|
||||
logicConditionStates[i].lastValue = 0;
|
||||
logicConditionStates[i].flags = 0;
|
||||
logicConditionStates[i].timeout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue