Skip to content

Commit 6f8634a

Browse files
fixed steppers not stopping from setSpeed(0) (#208)
* fixed steppers not stopping from setSpeed(0) * version bump and changelog * replaced float equality comparison with "less than" * removed custom ABS definition in favor of arduino abs * using type specific fabsf instead of generic abs
1 parent 5b31764 commit 6f8634a

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
**V1.12.2 - Updates**
2+
- Fixed a bug that caused Focuser stepper to misbehave after booting.
3+
14
**V1.12.1 - Updates**
25
- Fixed a bug that caused Autohoming to cause a build break.
36
- Fixed a bug that would prevent Hall sensor based Autohoming from completing.

Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// Also, numbers are interpreted as simple numbers. _ __ _
44
// So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/
55

6-
#define VERSION "V1.12.1"
6+
#define VERSION "V1.12.2"

src/InterruptAccelStepper.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
#include <stdint.h>
99
#include <math.h>
1010

11-
#define ABS(x) ((x >= 0) ? x : -x)
12-
1311
#define SIGN(x) ((x >= 0) ? 1 : -1)
1412

13+
// minimal stepping frequency (steps/s) based on cpu frequency, timer counter overflow and max amount of overflows
14+
#define MIN_STEPS_PER_SEC (static_cast<float>(F_CPU) / (UINT16_MAX * UINT8_MAX))
15+
1516
template <typename STEPPER> class InterruptAccelStepper
1617
{
1718
private:
@@ -47,7 +48,7 @@ template <typename STEPPER> class InterruptAccelStepper
4748
void setMaxSpeed(float speed)
4849
{
4950
LOG(DEBUG_STEPPERS, "[IAS-%d] setMaxSpeed(%f)", STEPPER::TIMER_ID, speed);
50-
_max_speed = ABS(speed);
51+
_max_speed = fabsf(speed);
5152
}
5253

5354
void setAcceleration(float value)
@@ -64,7 +65,15 @@ template <typename STEPPER> class InterruptAccelStepper
6465
{
6566
LOG(DEBUG_STEPPERS, "[IAS-%d] setSpeed(%f)", STEPPER::TIMER_ID, speed);
6667
_speed = speed;
67-
STEPPER::moveTo(_speed, INT32_MAX);
68+
69+
if (fabsf(speed) < MIN_STEPS_PER_SEC)
70+
{
71+
STEPPER::stop();
72+
}
73+
else
74+
{
75+
STEPPER::moveTo(_speed, INT32_MAX);
76+
}
6877
}
6978

7079
float speed()

0 commit comments

Comments
 (0)