mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 08:45:31 +03:00
Add the new logic conditions definitions
This commit is contained in:
parent
adaef39172
commit
8be0247dec
3 changed files with 56 additions and 3 deletions
|
@ -46,7 +46,7 @@ IPF can be edited using INAV Configurator user interface, of via CLI
|
|||
| 10 | NAND | |
|
||||
| 11 | NOR | |
|
||||
| 12 | NOT | |
|
||||
| 13 | STICKY | `Operand A` is activation operator, `Operand B` is deactivation operator. After activation, operator will return `true` until Operand B is evaluated as `true`|
|
||||
| 13 | STICKY | `Operand A` is the activation operator, `Operand B` is the deactivation operator. After activation, the operator will return `true` until Operand B is evaluated as `true`|
|
||||
| 14 | ADD | Add `Operand A` to `Operand B` 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 |
|
||||
|
@ -78,6 +78,8 @@ IPF can be edited using INAV Configurator user interface, of via CLI
|
|||
| 42 | SET_PROFILE | Sets the active config profile (PIDFF/Rates/Filters/etc) to `Operand A`. `Operand A` must be a valid profile number, currently from 1 to 3. If not, the profile will not change |
|
||||
| 43 | MIN | Finds the lowest value of `Operand A` and `Operand B` |
|
||||
| 44 | MAX | Finds the highest value of `Operand A` and `Operand B` |
|
||||
| 45 | FLIGTH_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 | FLIGTH_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 |
|
||||
|
||||
### Operands
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ PG_REGISTER_ARRAY_WITH_RESET_FN(logicCondition_t, MAX_LOGIC_CONDITIONS, logicCon
|
|||
EXTENDED_FASTRAM uint64_t logicConditionsGlobalFlags;
|
||||
EXTENDED_FASTRAM int logicConditionValuesByType[LOGIC_CONDITION_LAST];
|
||||
EXTENDED_FASTRAM rcChannelOverride_t rcChannelOverrides[MAX_SUPPORTED_RC_CHANNEL_COUNT];
|
||||
EXTENDED_FASTRAM flightAxisOverride_t flightAxisOverride[XYZ_AXIS_COUNT];
|
||||
|
||||
void pgResetFn_logicConditions(logicCondition_t *instance)
|
||||
{
|
||||
|
@ -364,6 +365,41 @@ static int logicConditionCompute(
|
|||
return true;
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_FLIGTH_AXIS_ANGLE_OVERRIDE:
|
||||
if (operandA >= 0 && operandA <= 2) {
|
||||
|
||||
flightAxisOverride[operandA].angleTargetActive = true;
|
||||
int target = DEGREES_TO_DECIDEGREES(operandB);
|
||||
if (operandA == 0) {
|
||||
//ROLL
|
||||
target = constrain(target, -pidProfile()->max_angle_inclination[FD_ROLL], pidProfile()->max_angle_inclination[FD_ROLL]);
|
||||
} else if (operandA == 1) {
|
||||
//PITCH
|
||||
target = constrain(target, -pidProfile()->max_angle_inclination[FD_PITCH], pidProfile()->max_angle_inclination[FD_PITCH]);
|
||||
} else if (operandA == 2) {
|
||||
//YAW
|
||||
target = (constrain(target, 0, 3600));
|
||||
}
|
||||
flightAxisOverride[operandA].angleTarget = target;
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_FLIGHT_AXIS);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case LOGIC_CONDITION_FLIGTH_AXIS_RATE_OVERRIDE:
|
||||
if (operandA >= 0 && operandA <= 2) {
|
||||
flightAxisOverride[operandA].rateTargetActive = true;
|
||||
flightAxisOverride[operandA].rateTarget = constrain(operandB, -2000, 2000);
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_ENABLE(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_FLIGHT_AXIS);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
|
@ -710,6 +746,11 @@ void logicConditionUpdateTask(timeUs_t currentTimeUs) {
|
|||
rcChannelOverrides[i].active = false;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < XYZ_AXIS_COUNT; i++) {
|
||||
flightAxisOverride[i].rateTargetActive = false;
|
||||
flightAxisOverride[i].angleTargetActive = false;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < MAX_LOGIC_CONDITIONS; i++) {
|
||||
logicConditionProcess(i);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,9 @@ typedef enum {
|
|||
LOGIC_CONDITION_SET_PROFILE = 42,
|
||||
LOGIC_CONDITION_MIN = 43,
|
||||
LOGIC_CONDITION_MAX = 44,
|
||||
LOGIC_CONDITION_LAST = 45,
|
||||
LOGIC_CONDITION_FLIGTH_AXIS_ANGLE_OVERRIDE = 45,
|
||||
LOGIC_CONDITION_FLIGTH_AXIS_RATE_OVERRIDE = 46,
|
||||
LOGIC_CONDITION_LAST = 47,
|
||||
} logicOperation_e;
|
||||
|
||||
typedef enum logicOperandType_s {
|
||||
|
@ -156,6 +158,7 @@ typedef enum {
|
|||
LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_OSD_LAYOUT = (1 << 7),
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_RC_CHANNEL = (1 << 8),
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_LOITER_RADIUS = (1 << 9),
|
||||
LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_FLIGHT_AXIS = (1 << 10),
|
||||
} logicConditionsGlobalFlags_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -188,6 +191,13 @@ typedef struct rcChannelOverride_s {
|
|||
int value;
|
||||
} rcChannelOverride_t;
|
||||
|
||||
typedef struct flightAxisOverride_s {
|
||||
uint8_t rateTargetActive;
|
||||
uint8_t angleTargetActive;
|
||||
int angleTarget;
|
||||
int rateTarget;
|
||||
} flightAxisOverride_t;
|
||||
|
||||
extern int logicConditionValuesByType[LOGIC_CONDITION_LAST];
|
||||
extern uint64_t logicConditionsGlobalFlags;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue