Merge pull request #7281 from mikeller/cleanup_dshot_defines
Cleaned up Dshot defines.
This commit is contained in:
commit
dfc0f347ba
|
@ -69,6 +69,8 @@ typedef enum {
|
||||||
DSHOT_CMD_MAX = 47
|
DSHOT_CMD_MAX = 47
|
||||||
} dshotCommands_e;
|
} dshotCommands_e;
|
||||||
|
|
||||||
|
#define DSHOT_MIN_THROTTLE 48
|
||||||
|
#define DSHOT_MAX_THROTTLE 2047
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PWM_TYPE_STANDARD = 0,
|
PWM_TYPE_STANDARD = 0,
|
||||||
|
|
|
@ -375,7 +375,7 @@ void initEscEndpoints(void)
|
||||||
case PWM_TYPE_DSHOT600:
|
case PWM_TYPE_DSHOT600:
|
||||||
case PWM_TYPE_DSHOT300:
|
case PWM_TYPE_DSHOT300:
|
||||||
case PWM_TYPE_DSHOT150:
|
case PWM_TYPE_DSHOT150:
|
||||||
disarmMotorOutput = DSHOT_DISARM_COMMAND;
|
disarmMotorOutput = DSHOT_CMD_MOTOR_STOP;
|
||||||
if (featureIsEnabled(FEATURE_3D)) {
|
if (featureIsEnabled(FEATURE_3D)) {
|
||||||
motorOutputLow = DSHOT_MIN_THROTTLE + ((DSHOT_3D_FORWARD_MIN_THROTTLE - 1 - DSHOT_MIN_THROTTLE) / 100.0f) * CONVERT_PARAMETER_TO_PERCENT(motorConfig()->digitalIdleOffsetValue);
|
motorOutputLow = DSHOT_MIN_THROTTLE + ((DSHOT_3D_FORWARD_MIN_THROTTLE - 1 - DSHOT_MIN_THROTTLE) / 100.0f) * CONVERT_PARAMETER_TO_PERCENT(motorConfig()->digitalIdleOffsetValue);
|
||||||
} else {
|
} else {
|
||||||
|
@ -941,14 +941,14 @@ float convertExternalToMotor(uint16_t externalValue)
|
||||||
|
|
||||||
if (featureIsEnabled(FEATURE_3D)) {
|
if (featureIsEnabled(FEATURE_3D)) {
|
||||||
if (externalValue == PWM_RANGE_MID) {
|
if (externalValue == PWM_RANGE_MID) {
|
||||||
motorValue = DSHOT_DISARM_COMMAND;
|
motorValue = DSHOT_CMD_MOTOR_STOP;
|
||||||
} else if (externalValue < PWM_RANGE_MID) {
|
} else if (externalValue < PWM_RANGE_MID) {
|
||||||
motorValue = scaleRange(externalValue, PWM_RANGE_MIN, PWM_RANGE_MID - 1, DSHOT_3D_FORWARD_MIN_THROTTLE - 1, DSHOT_MIN_THROTTLE);
|
motorValue = scaleRange(externalValue, PWM_RANGE_MIN, PWM_RANGE_MID - 1, DSHOT_3D_FORWARD_MIN_THROTTLE - 1, DSHOT_MIN_THROTTLE);
|
||||||
} else {
|
} else {
|
||||||
motorValue = scaleRange(externalValue, PWM_RANGE_MID + 1, PWM_RANGE_MAX, DSHOT_3D_FORWARD_MIN_THROTTLE, DSHOT_MAX_THROTTLE);
|
motorValue = scaleRange(externalValue, PWM_RANGE_MID + 1, PWM_RANGE_MAX, DSHOT_3D_FORWARD_MIN_THROTTLE, DSHOT_MAX_THROTTLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
motorValue = (externalValue == PWM_RANGE_MIN) ? DSHOT_DISARM_COMMAND : scaleRange(externalValue, PWM_RANGE_MIN + 1, PWM_RANGE_MAX, DSHOT_MIN_THROTTLE, DSHOT_MAX_THROTTLE);
|
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;
|
break;
|
||||||
|
@ -969,7 +969,7 @@ uint16_t convertMotorToExternal(float motorValue)
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
case true:
|
case true:
|
||||||
if (featureIsEnabled(FEATURE_3D)) {
|
if (featureIsEnabled(FEATURE_3D)) {
|
||||||
if (motorValue == DSHOT_DISARM_COMMAND || motorValue < DSHOT_MIN_THROTTLE) {
|
if (motorValue == DSHOT_CMD_MOTOR_STOP || motorValue < DSHOT_MIN_THROTTLE) {
|
||||||
externalValue = PWM_RANGE_MID;
|
externalValue = PWM_RANGE_MID;
|
||||||
} else if (motorValue <= DSHOT_3D_FORWARD_MIN_THROTTLE - 1) {
|
} else if (motorValue <= DSHOT_3D_FORWARD_MIN_THROTTLE - 1) {
|
||||||
externalValue = scaleRange(motorValue, DSHOT_MIN_THROTTLE, DSHOT_3D_FORWARD_MIN_THROTTLE - 1, PWM_RANGE_MID - 1, PWM_RANGE_MIN);
|
externalValue = scaleRange(motorValue, DSHOT_MIN_THROTTLE, DSHOT_3D_FORWARD_MIN_THROTTLE - 1, PWM_RANGE_MID - 1, PWM_RANGE_MIN);
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
#define BRUSHLESS_MOTORS_PWM_RATE 480
|
#define BRUSHLESS_MOTORS_PWM_RATE 480
|
||||||
|
|
||||||
// Digital protocol has fixed values
|
// Digital protocol has fixed values
|
||||||
#define DSHOT_DISARM_COMMAND 0
|
|
||||||
#define DSHOT_MIN_THROTTLE 48
|
|
||||||
#define DSHOT_MAX_THROTTLE 2047
|
|
||||||
#define DSHOT_3D_FORWARD_MIN_THROTTLE 1048
|
#define DSHOT_3D_FORWARD_MIN_THROTTLE 1048
|
||||||
|
|
||||||
// Note: this is called MultiType/MULTITYPE_* in baseflight.
|
// Note: this is called MultiType/MULTITYPE_* in baseflight.
|
||||||
|
|
Loading…
Reference in New Issue