mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
Keep sending DShot 0 packets between beacon commands (#12544)
* Keep sending DShot zero between beacon commands And don't wait 100ms between inline commands, which the beacon commands are. * use cmpTimeUs for time comparisons * Fixed intervals between DShot beacons * fix indentnation, thanks KarateBrot
This commit is contained in:
parent
26708ea425
commit
d9775287a2
4 changed files with 13 additions and 8 deletions
|
@ -239,7 +239,7 @@ void dshotCommandWrite(uint8_t index, uint8_t motorCount, uint8_t command, dshot
|
||||||
dshotCommandControl_t *commandControl = addCommand();
|
dshotCommandControl_t *commandControl = addCommand();
|
||||||
if (commandControl) {
|
if (commandControl) {
|
||||||
commandControl->repeats = repeats;
|
commandControl->repeats = repeats;
|
||||||
commandControl->delayAfterCommandUs = delayAfterCommandUs;
|
commandControl->delayAfterCommandUs = DSHOT_COMMAND_DELAY_US;
|
||||||
for (unsigned i = 0; i < motorCount; i++) {
|
for (unsigned i = 0; i < motorCount; i++) {
|
||||||
if (index == i || index == ALL_MOTORS) {
|
if (index == i || index == ALL_MOTORS) {
|
||||||
commandControl->command[i] = command;
|
commandControl->command[i] = command;
|
||||||
|
|
|
@ -495,7 +495,7 @@ void tryArm(void)
|
||||||
const timeUs_t currentTimeUs = micros();
|
const timeUs_t currentTimeUs = micros();
|
||||||
|
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (currentTimeUs - getLastDshotBeaconCommandTimeUs() < DSHOT_BEACON_GUARD_DELAY_US) {
|
if (cmpTimeUs(currentTimeUs, getLastDshotBeaconCommandTimeUs()) < DSHOT_BEACON_GUARD_DELAY_US) {
|
||||||
if (tryingToArm == ARMING_DELAYED_DISARMED) {
|
if (tryingToArm == ARMING_DELAYED_DISARMED) {
|
||||||
if (IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
if (IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
|
||||||
tryingToArm = ARMING_DELAYED_CRASHFLIP;
|
tryingToArm = ARMING_DELAYED_CRASHFLIP;
|
||||||
|
|
|
@ -400,19 +400,21 @@ void beeperUpdate(timeUs_t currentTimeUs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!beeperIsOn) {
|
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (!areMotorsRunning()
|
if (!areMotorsRunning() && (currentBeeperEntry->mode == BEEPER_RX_SET || currentBeeperEntry->mode == BEEPER_RX_LOST)) {
|
||||||
&& ((currentBeeperEntry->mode == BEEPER_RX_SET && !(beeperConfig()->dshotBeaconOffFlags & BEEPER_GET_FLAG(BEEPER_RX_SET)))
|
if (cmpTimeUs(currentTimeUs, getLastDisarmTimeUs()) > DSHOT_BEACON_GUARD_DELAY_US && !isTryingToArm()) {
|
||||||
|| (currentBeeperEntry->mode == BEEPER_RX_LOST && !(beeperConfig()->dshotBeaconOffFlags & BEEPER_GET_FLAG(BEEPER_RX_LOST))))) {
|
const timeDelta_t dShotBeaconInterval = (currentBeeperEntry->mode == BEEPER_RX_SET) ? DSHOT_BEACON_MODE_INTERVAL_US : DSHOT_BEACON_RXLOSS_INTERVAL_US;
|
||||||
|
if (cmpTimeUs(currentTimeUs, lastDshotBeaconCommandTimeUs) > dShotBeaconInterval) {
|
||||||
if ((currentTimeUs - getLastDisarmTimeUs() > DSHOT_BEACON_GUARD_DELAY_US) && !isTryingToArm()) {
|
// at least 500ms between DShot beacons to allow time for the sound to fully complete
|
||||||
|
// the DShot Beacon tone duration is determined by the ESC, and should not exceed 250ms
|
||||||
lastDshotBeaconCommandTimeUs = currentTimeUs;
|
lastDshotBeaconCommandTimeUs = currentTimeUs;
|
||||||
dshotCommandWrite(ALL_MOTORS, getMotorCount(), beeperConfig()->dshotBeaconTone, DSHOT_CMD_TYPE_INLINE);
|
dshotCommandWrite(ALL_MOTORS, getMotorCount(), beeperConfig()->dshotBeaconTone, DSHOT_CMD_TYPE_INLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!beeperIsOn) {
|
||||||
if (currentBeeperEntry->sequence[beeperPos] != 0) {
|
if (currentBeeperEntry->sequence[beeperPos] != 0) {
|
||||||
if (!(beeperConfig()->beeper_off_flags & BEEPER_GET_FLAG(currentBeeperEntry->mode))) {
|
if (!(beeperConfig()->beeper_off_flags & BEEPER_GET_FLAG(currentBeeperEntry->mode))) {
|
||||||
BEEP_ON;
|
BEEP_ON;
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
#define DSHOT_BEACON_GUARD_DELAY_US 1200000 // Time to separate dshot beacon and armining/disarming events
|
#define DSHOT_BEACON_GUARD_DELAY_US 1200000 // Time to separate dshot beacon and armining/disarming events
|
||||||
// to prevent interference with motor direction commands
|
// to prevent interference with motor direction commands
|
||||||
|
#define DSHOT_BEACON_MODE_INTERVAL_US 450000 // at least 450ms between successive DShot beacon iterations to allow time for ESC to play tone
|
||||||
|
#define DSHOT_BEACON_RXLOSS_INTERVAL_US 950000 // at least 950ms between successive DShot beacon iterations to allow time for ESC to play tone
|
||||||
|
// we check beeper every 100ms, so these result in 500ms and 1.0s in practice
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue