Skip to content

Commit

Permalink
Hack inertia params into old dynamic precomps
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattila committed Jan 11, 2025
1 parent c5dd8c8 commit d6ccf92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/main/fc/rc_adjustments.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ static int getAdjustmentValue(adjustmentFunc_e adjFunc)
value = currentPidProfile->yaw_collective_ff_gain;
break;
case ADJUSTMENT_YAW_COLLECTIVE_DYN:
value = 0;
value = currentPidProfile->yaw_inertia_precomp_gain;
break;
case ADJUSTMENT_YAW_COLLECTIVE_DECAY:
value = 0;
value = currentPidProfile->yaw_inertia_precomp_cutoff;
break;
case ADJUSTMENT_PITCH_COLLECTIVE_FF:
value = currentPidProfile->pitch_collective_ff_gain;
Expand Down Expand Up @@ -500,8 +500,10 @@ static void setAdjustmentValue(adjustmentFunc_e adjFunc, int value)
currentPidProfile->yaw_collective_ff_gain = value;
break;
case ADJUSTMENT_YAW_COLLECTIVE_DYN:
currentPidProfile->yaw_inertia_precomp_gain = value;
break;
case ADJUSTMENT_YAW_COLLECTIVE_DECAY:
currentPidProfile->yaw_inertia_precomp_cutoff = value;
break;
case ADJUSTMENT_PITCH_COLLECTIVE_FF:
currentPidProfile->pitch_collective_ff_gain = value;
Expand Down
16 changes: 4 additions & 12 deletions src/main/msp/msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,8 +1820,8 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
sbufWriteU8(dst, currentPidProfile->yaw_precomp_cutoff);
sbufWriteU8(dst, currentPidProfile->yaw_cyclic_ff_gain);
sbufWriteU8(dst, currentPidProfile->yaw_collective_ff_gain);
sbufWriteU8(dst, 0); // was currentPidProfile->yaw_collective_dynamic_gain
sbufWriteU8(dst, 0); // was currentPidProfile->yaw_collective_dynamic_decay
sbufWriteU8(dst, currentPidProfile->yaw_inertia_precomp_gain);
sbufWriteU8(dst, currentPidProfile->yaw_inertia_precomp_cutoff);
sbufWriteU8(dst, currentPidProfile->pitch_collective_ff_gain);
/* Angle mode */
sbufWriteU8(dst, currentPidProfile->angle.level_strength);
Expand All @@ -1842,9 +1842,6 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
sbufWriteU8(dst, currentPidProfile->bterm_cutoff[0]);
sbufWriteU8(dst, currentPidProfile->bterm_cutoff[1]);
sbufWriteU8(dst, currentPidProfile->bterm_cutoff[2]);
/* Inertia precomps */
sbufWriteU8(dst, currentPidProfile->yaw_inertia_precomp_gain);
sbufWriteU8(dst, currentPidProfile->yaw_inertia_precomp_cutoff);
break;

case MSP_RESCUE_PROFILE:
Expand Down Expand Up @@ -2624,8 +2621,8 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
currentPidProfile->yaw_precomp_cutoff = sbufReadU8(src);
currentPidProfile->yaw_cyclic_ff_gain = sbufReadU8(src);
currentPidProfile->yaw_collective_ff_gain = sbufReadU8(src);
sbufReadU8(src); // was currentPidProfile->yaw_collective_dynamic_gain
sbufReadU8(src); // was currentPidProfile->yaw_collective_dynamic_decay
currentPidProfile->yaw_inertia_precomp_gain = sbufReadU8(src);
currentPidProfile->yaw_inertia_precomp_cutoff = sbufReadU8(src);
currentPidProfile->pitch_collective_ff_gain = sbufReadU8(src);
/* Angle mode */
currentPidProfile->angle.level_strength = sbufReadU8(src);
Expand All @@ -2652,11 +2649,6 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
currentPidProfile->bterm_cutoff[1] = sbufReadU8(src);
currentPidProfile->bterm_cutoff[2] = sbufReadU8(src);
}
/* Inertia precomps */
if (sbufBytesRemaining(src) >= 2) {
currentPidProfile->yaw_inertia_precomp_gain = sbufReadU8(src);
currentPidProfile->yaw_inertia_precomp_cutoff = sbufReadU8(src);
}
/* Load new values */
pidInitProfile(currentPidProfile);
break;
Expand Down

0 comments on commit d6ccf92

Please sign in to comment.