mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 01:35:35 +03:00
Logic Conditions framework (#4144)
* CLI for servo mix conditions * RC channel greater than on servo mixer * RC channel value based conditions * MSP2 frames * Docs update * mixer condition changed to logic condition and generalized * basic logic framwork extarcted to separate file' * minor fixes * Processing refactoring * Flight values added to conditions * Use logic conditions only on > F3 * Make logic conditions a separate entity and link from servo mixer to logic condition * empty task to periadically compute logic conditions * Compute logic conditions as task * Add flags * CLI logic to configure logic conditions * MSP frames to get and set logic conditions * Disabled condition always yelds false * fixes for F3 * Review changes * final fix in MSP2_INAV_SERVO_MIXER
This commit is contained in:
parent
2ea69cf1f8
commit
c13a13b172
12 changed files with 604 additions and 14 deletions
|
@ -463,6 +463,32 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
|
|||
sbufWriteU8(dst, 0);
|
||||
}
|
||||
break;
|
||||
case MSP2_INAV_SERVO_MIXER:
|
||||
for (int i = 0; i < MAX_SERVO_RULES; i++) {
|
||||
sbufWriteU8(dst, customServoMixers(i)->targetChannel);
|
||||
sbufWriteU8(dst, customServoMixers(i)->inputSource);
|
||||
sbufWriteU16(dst, customServoMixers(i)->rate);
|
||||
sbufWriteU8(dst, customServoMixers(i)->speed);
|
||||
#ifdef USE_LOGIC_CONDITIONS
|
||||
sbufWriteU8(dst, customServoMixers(i)->conditionId);
|
||||
#else
|
||||
sbufWriteU8(dst, 0);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#ifdef USE_LOGIC_CONDITIONS
|
||||
case MSP2_INAV_LOGIC_CONDITIONS:
|
||||
for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) {
|
||||
sbufWriteU8(dst, logicConditions(i)->enabled);
|
||||
sbufWriteU8(dst, logicConditions(i)->operation);
|
||||
sbufWriteU8(dst, logicConditions(i)->operandA.type);
|
||||
sbufWriteU32(dst, logicConditions(i)->operandA.value);
|
||||
sbufWriteU8(dst, logicConditions(i)->operandB.type);
|
||||
sbufWriteU32(dst, logicConditions(i)->operandB.value);
|
||||
sbufWriteU8(dst, logicConditions(i)->flags);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case MSP2_COMMON_MOTOR_MIXER:
|
||||
for (uint8_t i = 0; i < MAX_SUPPORTED_MOTORS; i++) {
|
||||
sbufWriteU16(dst, customMotorMixer(i)->throttle * 1000);
|
||||
|
@ -1823,7 +1849,38 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
|
|||
} else
|
||||
return MSP_RESULT_ERROR;
|
||||
break;
|
||||
|
||||
|
||||
case MSP2_INAV_SET_SERVO_MIXER:
|
||||
sbufReadU8Safe(&tmp_u8, src);
|
||||
if ((dataSize == 7) && (tmp_u8 < MAX_SERVO_RULES)) {
|
||||
customServoMixersMutable(tmp_u8)->targetChannel = sbufReadU8(src);
|
||||
customServoMixersMutable(tmp_u8)->inputSource = sbufReadU8(src);
|
||||
customServoMixersMutable(tmp_u8)->rate = sbufReadU16(src);
|
||||
customServoMixersMutable(tmp_u8)->speed = sbufReadU8(src);
|
||||
#ifdef USE_LOGIC_CONDITIONS
|
||||
customServoMixersMutable(tmp_u8)->conditionId = sbufReadU8(src);
|
||||
#else
|
||||
sbufReadU8(src);
|
||||
#endif
|
||||
loadCustomServoMixer();
|
||||
} else
|
||||
return MSP_RESULT_ERROR;
|
||||
break;
|
||||
#ifdef USE_LOGIC_CONDITIONS
|
||||
case MSP2_INAV_SET_LOGIC_CONDITIONS:
|
||||
sbufReadU8Safe(&tmp_u8, src);
|
||||
if ((dataSize == 13) && (tmp_u8 < MAX_LOGIC_CONDITIONS)) {
|
||||
logicConditionsMutable(tmp_u8)->enabled = sbufReadU8(src);
|
||||
logicConditionsMutable(tmp_u8)->operation = sbufReadU8(src);
|
||||
logicConditionsMutable(tmp_u8)->operandA.type = sbufReadU8(src);
|
||||
logicConditionsMutable(tmp_u8)->operandA.value = sbufReadU32(src);
|
||||
logicConditionsMutable(tmp_u8)->operandB.type = sbufReadU8(src);
|
||||
logicConditionsMutable(tmp_u8)->operandB.value = sbufReadU32(src);
|
||||
logicConditionsMutable(tmp_u8)->flags = sbufReadU8(src);
|
||||
} else
|
||||
return MSP_RESULT_ERROR;
|
||||
break;
|
||||
#endif
|
||||
case MSP2_COMMON_SET_MOTOR_MIXER:
|
||||
sbufReadU8Safe(&tmp_u8, src);
|
||||
if ((dataSize == 9) && (tmp_u8 < MAX_SUPPORTED_MOTORS)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue