Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rate Dynamics to MSP #9336

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,21 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
break;
#endif

#ifdef USE_RATE_DYNAMICS

case MSP2_INAV_RATE_DYNAMICS:
{
sbufWriteU8(dst, currentControlRateProfile->rateDynamics.sensitivityCenter);
sbufWriteU8(dst, currentControlRateProfile->rateDynamics.sensitivityEnd);
sbufWriteU8(dst, currentControlRateProfile->rateDynamics.correctionCenter);
sbufWriteU8(dst, currentControlRateProfile->rateDynamics.correctionEnd);
sbufWriteU8(dst, currentControlRateProfile->rateDynamics.weightCenter);
sbufWriteU8(dst, currentControlRateProfile->rateDynamics.weightEnd);
}
break;

#endif

default:
return false;
}
Expand Down Expand Up @@ -3040,6 +3055,27 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
break;
#endif

#ifdef USE_RATE_DYNAMICS

case MSP2_INAV_SET_RATE_DYNAMICS:

if (dataSize == 8) {
((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.sensitivityCenter = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.sensitivityEnd = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.correctionCenter = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.correctionEnd = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.weightCenter = sbufReadU8(src);
((controlRateConfig_t*)currentControlRateProfile)->rateDynamics.weightEnd = sbufReadU8(src);

} else {
return MSP_RESULT_ERROR;
}

break;

#endif


default:
return MSP_RESULT_ERROR;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/msp/msp_protocol_v2_inav.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@
#define MSP2_INAV_LED_STRIP_CONFIG_EX 0x2048
#define MSP2_INAV_SET_LED_STRIP_CONFIG_EX 0x2049

#define MSP2_INAV_RATE_DYNAMICS 0x2060
#define MSP2_INAV_SET_RATE_DYNAMICS 0x2061