Skip to content

Commit 58e983f

Browse files
committed
Fix: Preserve direction-change commands when stopping motors
Use stopAllMotors() instead of stopAllMotorsNow() to avoid clearing the command queue. This ensures direction-change and SAVE_SETTINGS commands complete even when spacebar is released or dialog is closed. stopAllMotorsNow() retains its original behavior (clears queue) for emergency stop scenarios where immediate halt is required.
1 parent 494c252 commit 58e983f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/components/EscDshotDirection/EscDshotDirectionComponent.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ class EscDshotDirectionComponent {
419419
return;
420420
}
421421

422-
// SPACEBAR RELEASE: Stop motors immediately
422+
// SPACEBAR RELEASE: Stop motors (preserves pending direction changes)
423+
// Motors stop immediately unless direction change is in progress (~100ms delay)
423424
if (event.code === "Space") {
424425
event.preventDefault();
425426
event.stopPropagation();
@@ -435,7 +436,7 @@ class EscDshotDirectionComponent {
435436
}
436437

437438
_handleSpacebarRelease() {
438-
this._motorDriver.stopAllMotorsNow();
439+
this._motorDriver.stopAllMotors();
439440
}
440441

441442
_handleWindowBlur() {
@@ -475,11 +476,11 @@ class EscDshotDirectionComponent {
475476
this._deactivateWizardMotorButtons();
476477
}
477478

478-
// Stop motors (this adds stop commands to the queue)
479-
this._motorDriver.stopAllMotorsNow();
479+
// Stop motors - adds stop commands to end of queue (preserves pending direction changes)
480+
this._motorDriver.stopAllMotors();
480481

481-
// Deactivate motor driver - this tells queue to stop AFTER processing current commands
482-
// This is critical - it allows direction change + save commands to complete
482+
// Deactivate motor driver - prevents new commands and stops queue when empty
483+
// Queue will drain naturally, completing any pending direction change + save commands
483484
this._motorDriver.deactivate();
484485

485486
// Clear wizard flag after motor driver deactivation
@@ -570,7 +571,7 @@ class EscDshotDirectionComponent {
570571
_onStopWizardButtonClicked() {
571572
this._domSpinWizardButton.toggle(true);
572573
this._domSpinningWizard.toggle(false);
573-
this._motorDriver.stopAllMotorsNow();
574+
this._motorDriver.stopAllMotors();
574575
this._deactivateWizardMotorButtons();
575576

576577
// NEW: Disable keyboard shortcuts when wizard stops

0 commit comments

Comments
 (0)