mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 11:29:56 +03:00
Merge branch 'master' of https://github.com/RomanLut/inav into submit-gps-fix-estimation
removed GPS Off box implemented Disable GPS sensor fix logic condition
This commit is contained in:
commit
cb2d448911
379 changed files with 5433 additions and 3656 deletions
|
@ -35,6 +35,7 @@
|
|||
#include "rx/rx.h"
|
||||
#include "common/maths.h"
|
||||
#include "fc/config.h"
|
||||
#include "fc/cli.h"
|
||||
#include "fc/fc_core.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
@ -85,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;
|
||||
|
@ -103,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;
|
||||
|
@ -158,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:
|
||||
|
@ -400,6 +469,15 @@ static int logicConditionCompute(
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_DISABLE_GPS_FIX:
|
||||
if (operandA > 0) {
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_DISABLE_GPS_FIX);
|
||||
} else {
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_DISABLE(LOGIC_CONDITION_GLOBAL_FLAG_DISABLE_GPS_FIX);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -411,7 +489,7 @@ void logicConditionProcess(uint8_t i) {
|
|||
|
||||
const int activatorValue = logicConditionGetValue(logicConditions(i)->activatorId);
|
||||
|
||||
if (logicConditions(i)->enabled && activatorValue) {
|
||||
if (logicConditions(i)->enabled && activatorValue && !cliMode) {
|
||||
|
||||
/*
|
||||
* Process condition only when latch flag is not set
|
||||
|
@ -424,7 +502,8 @@ void logicConditionProcess(uint8_t i) {
|
|||
logicConditionStates[i].value,
|
||||
logicConditions(i)->operation,
|
||||
operandAValue,
|
||||
operandBValue
|
||||
operandBValue,
|
||||
i
|
||||
);
|
||||
|
||||
logicConditionStates[i].value = newValue;
|
||||
|
@ -687,6 +766,10 @@ static int logicConditionGetFlightModeOperandValue(int operand) {
|
|||
return IS_RC_MODE_ACTIVE(BOXUSER3);
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_OPERAND_FLIGHT_MODE_USER4:
|
||||
return IS_RC_MODE_ACTIVE(BOXUSER4);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
|
@ -780,7 +863,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