From 4133a72c332ae3c2c3a3cc92021316d15e450b11 Mon Sep 17 00:00:00 2001 From: 94xhn <87560781+94xhn@users.noreply.github.com> Date: Thu, 16 Jul 2026 15:04:45 +0800 Subject: [PATCH] Fix off-by-one in moveTimed() duration chunking at 131072 boundary When this_duration == 131072 exactly, the check `this_duration > 131072` falls through to the `this_duration > 65535` branch, which computes this_duration / 2 == 65536. Since cmd.ticks is a uint16_t, this silently truncates to 0, causing addQueueEntry() to reject the command with AQE_ERROR_TICKS_TOO_LOW and moveTimed() to return an error for an otherwise perfectly ordinary single-step move. Changing the comparison to >= mirrors the already-correct sibling check in the steps==0 loop above (line 768: `duration >= 131072`), which never exhibits this bug. --- src/FastAccelStepper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FastAccelStepper.cpp b/src/FastAccelStepper.cpp index 32c3818f..e79f76f9 100644 --- a/src/FastAccelStepper.cpp +++ b/src/FastAccelStepper.cpp @@ -817,7 +817,7 @@ MoveTimedResultCode FastAccelStepper::moveTimed(int16_t steps, uint32_t this_duration = rate; cmd.steps = 1; while (this_duration) { - if (this_duration > 131072) { + if (this_duration >= 131072) { cmd.ticks = 65535; } else if (this_duration > 65535) { cmd.ticks = this_duration / 2;