1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 11:59:58 +03:00

Refactored Dshot enabled checks.

This commit is contained in:
mikeller 2020-06-22 01:31:51 +12:00
parent 97ad043f9e
commit c2812eca8c
3 changed files with 20 additions and 8 deletions

View file

@ -151,17 +151,29 @@ static bool allMotorsAreIdle(void)
return true;
}
bool dshotCommandsAreEnabled(dshotCommandType_e commandType)
bool dshotStreamingCommandsAreEnabled(void)
{
return motorIsEnabled() && motorGetMotorEnableTimeMs() && millis() > motorGetMotorEnableTimeMs() + DSHOT_PROTOCOL_DETECTION_DELAY_MS;
}
static bool dshotCommandsAreEnabled(dshotCommandType_e commandType)
{
bool ret = false;
if (commandType == DSHOT_CMD_TYPE_BLOCKING) {
switch (commandType) {
case DSHOT_CMD_TYPE_BLOCKING:
ret = !motorIsEnabled();
} else if (commandType == DSHOT_CMD_TYPE_INLINE) {
if (motorIsEnabled() && motorGetMotorEnableTimeMs() && millis() > motorGetMotorEnableTimeMs() + DSHOT_PROTOCOL_DETECTION_DELAY_MS) {
ret = true;
}
break;
case DSHOT_CMD_TYPE_INLINE:
ret = dshotStreamingCommandsAreEnabled();
break;
default:
break;
}
return ret;
}