mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Merge pull request #6798 from etracer65/3d_deadband_fix
Fix zero throttle deadband when using switched 3D modes
This commit is contained in:
commit
b057ce550d
1 changed files with 19 additions and 9 deletions
|
@ -320,9 +320,7 @@ const mixer_t mixers[] = {
|
||||||
FAST_RAM_ZERO_INIT float motorOutputHigh, motorOutputLow;
|
FAST_RAM_ZERO_INIT float motorOutputHigh, motorOutputLow;
|
||||||
|
|
||||||
static FAST_RAM_ZERO_INIT float disarmMotorOutput, deadbandMotor3dHigh, deadbandMotor3dLow;
|
static FAST_RAM_ZERO_INIT float disarmMotorOutput, deadbandMotor3dHigh, deadbandMotor3dLow;
|
||||||
static FAST_RAM_ZERO_INIT uint16_t rcCommand3dDeadBandLow;
|
static FAST_RAM_ZERO_INIT float rcCommandThrottleRange;
|
||||||
static FAST_RAM_ZERO_INIT uint16_t rcCommand3dDeadBandHigh;
|
|
||||||
static FAST_RAM_ZERO_INIT float rcCommandThrottleRange, rcCommandThrottleRange3dLow, rcCommandThrottleRange3dHigh;
|
|
||||||
|
|
||||||
uint8_t getMotorCount(void)
|
uint8_t getMotorCount(void)
|
||||||
{
|
{
|
||||||
|
@ -401,12 +399,6 @@ void initEscEndpoints(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
rcCommandThrottleRange = PWM_RANGE_MAX - rxConfig()->mincheck;
|
rcCommandThrottleRange = PWM_RANGE_MAX - rxConfig()->mincheck;
|
||||||
|
|
||||||
rcCommand3dDeadBandLow = rxConfig()->midrc - flight3DConfig()->deadband3d_throttle;
|
|
||||||
rcCommand3dDeadBandHigh = rxConfig()->midrc + flight3DConfig()->deadband3d_throttle;
|
|
||||||
|
|
||||||
rcCommandThrottleRange3dLow = rcCommand3dDeadBandLow - PWM_RANGE_MIN;
|
|
||||||
rcCommandThrottleRange3dHigh = PWM_RANGE_MAX - rcCommand3dDeadBandHigh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mixerInit(mixerMode_e mixerMode)
|
void mixerInit(mixerMode_e mixerMode)
|
||||||
|
@ -528,10 +520,28 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
|
||||||
float currentThrottleInputRange = 0;
|
float currentThrottleInputRange = 0;
|
||||||
|
|
||||||
if (featureIsEnabled(FEATURE_3D)) {
|
if (featureIsEnabled(FEATURE_3D)) {
|
||||||
|
uint16_t rcCommand3dDeadBandLow;
|
||||||
|
uint16_t rcCommand3dDeadBandHigh;
|
||||||
|
|
||||||
if (!ARMING_FLAG(ARMED)) {
|
if (!ARMING_FLAG(ARMED)) {
|
||||||
rcThrottlePrevious = rxConfig()->midrc; // When disarmed set to mid_rc. It always results in positive direction after arming.
|
rcThrottlePrevious = rxConfig()->midrc; // When disarmed set to mid_rc. It always results in positive direction after arming.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_RC_MODE_ACTIVE(BOX3D) || flight3DConfig()->switched_mode3d) {
|
||||||
|
// The min_check range is halved because the output throttle is scaled to 500us.
|
||||||
|
// So by using half of min_check we maintain the same low-throttle deadband
|
||||||
|
// stick travel as normal non-3D mode.
|
||||||
|
const int mincheckOffset = (rxConfig()->mincheck - PWM_RANGE_MIN) / 2;
|
||||||
|
rcCommand3dDeadBandLow = rxConfig()->midrc - mincheckOffset;
|
||||||
|
rcCommand3dDeadBandHigh = rxConfig()->midrc + mincheckOffset;
|
||||||
|
} else {
|
||||||
|
rcCommand3dDeadBandLow = rxConfig()->midrc - flight3DConfig()->deadband3d_throttle;
|
||||||
|
rcCommand3dDeadBandHigh = rxConfig()->midrc + flight3DConfig()->deadband3d_throttle;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float rcCommandThrottleRange3dLow = rcCommand3dDeadBandLow - PWM_RANGE_MIN;
|
||||||
|
const float rcCommandThrottleRange3dHigh = PWM_RANGE_MAX - rcCommand3dDeadBandHigh;
|
||||||
|
|
||||||
if (rcCommand[THROTTLE] <= rcCommand3dDeadBandLow) {
|
if (rcCommand[THROTTLE] <= rcCommand3dDeadBandLow) {
|
||||||
// INVERTED
|
// INVERTED
|
||||||
motorRangeMin = motorOutputLow;
|
motorRangeMin = motorOutputLow;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue