Skip to content
Open
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
12 changes: 9 additions & 3 deletions src/main/navigation/navigation_multicopter.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,15 @@ bool adjustMulticopterAltitudeFromRCInput(void)
/* Set velocity proportional to stick movement
* Scale from altHoldThrottleRCZero to maxthrottle or minthrottle to altHoldThrottleRCZero */

// Calculate max up or min down limit value scaled for deadband
int16_t limitValue = rcThrottleAdjustment > 0 ? getMaxThrottle() : getThrottleIdleValue();
limitValue = applyDeadbandRescaled(limitValue - altHoldThrottleRCZero, rcControlsConfig()->alt_hold_deadband, -500, 500);
// Calculate max up or min down limit value (raw range, deadband already applied to rcThrottleAdjustment)
int16_t limitValue = rcThrottleAdjustment > 0 ?
(getMaxThrottle() - altHoldThrottleRCZero) :
(altHoldThrottleRCZero - getThrottleIdleValue());

// Defensive check - should never trigger with valid configuration
if (limitValue <= 0) {
limitValue = 1; // Prevent division by zero/negative
}

int16_t rcClimbRate = ABS(rcThrottleAdjustment) * navConfig()->mc.max_manual_climb_rate / limitValue;
updateClimbRateToAltitudeController(rcClimbRate, 0, ROC_TO_ALT_CONSTANT);
Expand Down