mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Fix compilation when USE_DSHOT and USE_PWM_OUTPUT are not defined.
Fix compilation when USE_DMA and USE_DMA_SPEC are not defined. Cleanup calling code of `isMotorProtocolDshot`. Fix 'unused' warning when USE_PWM_OUTPUT is not defined. Undo isMotoroProtocolDshot change. Disable USE_SERIAL_4WAY_BLHELI_INTERFACE when USE_PWM_OUTPUT is not enabled. Style cleanup.
This commit is contained in:
parent
1631831147
commit
1f2ef98042
7 changed files with 46 additions and 22 deletions
|
@ -557,17 +557,22 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
|
|||
// INVERTED
|
||||
motorRangeMin = motorOutputLow;
|
||||
motorRangeMax = deadbandMotor3dLow;
|
||||
#ifdef USE_DSHOT
|
||||
if (isMotorProtocolDshot()) {
|
||||
motorOutputMin = motorOutputLow;
|
||||
motorOutputRange = deadbandMotor3dLow - motorOutputLow;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
motorOutputMin = deadbandMotor3dLow;
|
||||
motorOutputRange = motorOutputLow - deadbandMotor3dLow;
|
||||
}
|
||||
|
||||
if (motorOutputMixSign != -1) {
|
||||
reversalTimeUs = currentTimeUs;
|
||||
}
|
||||
motorOutputMixSign = -1;
|
||||
|
||||
rcThrottlePrevious = rcCommand[THROTTLE];
|
||||
throttle = rcCommand3dDeadBandLow - rcCommand[THROTTLE];
|
||||
currentThrottleInputRange = rcCommandThrottleRange3dLow;
|
||||
|
@ -590,17 +595,23 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs)
|
|||
// INVERTED_TO_DEADBAND
|
||||
motorRangeMin = motorOutputLow;
|
||||
motorRangeMax = deadbandMotor3dLow;
|
||||
|
||||
#ifdef USE_DSHOT
|
||||
if (isMotorProtocolDshot()) {
|
||||
motorOutputMin = motorOutputLow;
|
||||
motorOutputRange = deadbandMotor3dLow - motorOutputLow;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
motorOutputMin = deadbandMotor3dLow;
|
||||
motorOutputRange = motorOutputLow - deadbandMotor3dLow;
|
||||
}
|
||||
|
||||
if (motorOutputMixSign != -1) {
|
||||
reversalTimeUs = currentTimeUs;
|
||||
}
|
||||
motorOutputMixSign = -1;
|
||||
|
||||
throttle = 0;
|
||||
currentThrottleInputRange = rcCommandThrottleRange3dLow;
|
||||
} else {
|
||||
|
@ -720,9 +731,11 @@ static void applyMixToMotors(float motorMix[MAX_SUPPORTED_MOTORS], motorMixer_t
|
|||
}
|
||||
#endif
|
||||
if (failsafeIsActive()) {
|
||||
#ifdef USE_DSHOT
|
||||
if (isMotorProtocolDshot()) {
|
||||
motorOutput = (motorOutput < motorRangeMin) ? disarmMotorOutput : motorOutput; // Prevent getting into special reserved range
|
||||
}
|
||||
#endif
|
||||
motorOutput = constrain(motorOutput, disarmMotorOutput, motorRangeMax);
|
||||
} else {
|
||||
motorOutput = constrain(motorOutput, motorRangeMin, motorRangeMax);
|
||||
|
@ -940,9 +953,8 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensa
|
|||
float convertExternalToMotor(uint16_t externalValue)
|
||||
{
|
||||
uint16_t motorValue;
|
||||
switch ((int)isMotorProtocolDshot()) {
|
||||
#ifdef USE_DSHOT
|
||||
case true:
|
||||
if (isMotorProtocolDshot()) {
|
||||
externalValue = constrain(externalValue, PWM_RANGE_MIN, PWM_RANGE_MAX);
|
||||
|
||||
if (featureIsEnabled(FEATURE_3D)) {
|
||||
|
@ -956,13 +968,11 @@ float convertExternalToMotor(uint16_t externalValue)
|
|||
} else {
|
||||
motorValue = (externalValue == PWM_RANGE_MIN) ? DSHOT_CMD_MOTOR_STOP : scaleRange(externalValue, PWM_RANGE_MIN + 1, PWM_RANGE_MAX, DSHOT_MIN_THROTTLE, DSHOT_MAX_THROTTLE);
|
||||
}
|
||||
|
||||
break;
|
||||
case false:
|
||||
}
|
||||
else
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
motorValue = externalValue;
|
||||
break;
|
||||
}
|
||||
|
||||
return (float)motorValue;
|
||||
|
@ -971,9 +981,8 @@ float convertExternalToMotor(uint16_t externalValue)
|
|||
uint16_t convertMotorToExternal(float motorValue)
|
||||
{
|
||||
uint16_t externalValue;
|
||||
switch ((int)isMotorProtocolDshot()) {
|
||||
#ifdef USE_DSHOT
|
||||
case true:
|
||||
if (isMotorProtocolDshot()) {
|
||||
if (featureIsEnabled(FEATURE_3D)) {
|
||||
if (motorValue == DSHOT_CMD_MOTOR_STOP || motorValue < DSHOT_MIN_THROTTLE) {
|
||||
externalValue = PWM_RANGE_MID;
|
||||
|
@ -985,12 +994,11 @@ uint16_t convertMotorToExternal(float motorValue)
|
|||
} else {
|
||||
externalValue = (motorValue < DSHOT_MIN_THROTTLE) ? PWM_RANGE_MIN : scaleRange(motorValue, DSHOT_MIN_THROTTLE, DSHOT_MAX_THROTTLE, PWM_RANGE_MIN + 1, PWM_RANGE_MAX);
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
}
|
||||
else
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
externalValue = motorValue;
|
||||
break;
|
||||
}
|
||||
|
||||
return externalValue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue