mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Merge pull request #3636 from basdelfos/copy-profile
Copy profile to another profile (MSP and OSD)
This commit is contained in:
commit
e3a921b762
8 changed files with 109 additions and 0 deletions
|
@ -71,3 +71,11 @@ void changeControlRateProfile(uint8_t controlRateProfileIndex)
|
|||
setControlRateProfile(controlRateProfileIndex);
|
||||
generateThrottleCurve();
|
||||
}
|
||||
|
||||
void copyControlRateProfile(const uint8_t dstControlRateProfileIndex, const uint8_t srcControlRateProfileIndex) {
|
||||
if ((dstControlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT-1 && srcControlRateProfileIndex < CONTROL_RATE_PROFILE_COUNT-1)
|
||||
&& dstControlRateProfileIndex != srcControlRateProfileIndex
|
||||
) {
|
||||
memcpy(controlRateProfilesMutable(dstControlRateProfileIndex), controlRateProfilesMutable(srcControlRateProfileIndex), sizeof(controlRateConfig_t));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,3 +41,5 @@ extern controlRateConfig_t *currentControlRateProfile;
|
|||
|
||||
void setControlRateProfile(uint8_t controlRateProfileIndex);
|
||||
void changeControlRateProfile(uint8_t controlRateProfileIndex);
|
||||
|
||||
void copyControlRateProfile(const uint8_t dstControlRateProfileIndex, const uint8_t srcControlRateProfileIndex);
|
||||
|
|
|
@ -1314,6 +1314,18 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
}
|
||||
break;
|
||||
|
||||
case MSP_COPY_PROFILE:
|
||||
value = sbufReadU8(src); // 0 = pid profile, 1 = control rate profile
|
||||
uint8_t dstProfileIndex = sbufReadU8(src);
|
||||
uint8_t srcProfileIndex = sbufReadU8(src);
|
||||
if (value == 0) {
|
||||
copyPidProfile(dstProfileIndex, srcProfileIndex);
|
||||
}
|
||||
else if (value == 1) {
|
||||
copyControlRateProfile(dstProfileIndex, srcProfileIndex);
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined(GPS) || defined(MAG)
|
||||
case MSP_SET_HEADING:
|
||||
magHold = sbufReadU16(src);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue