File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,12 @@ void Stepper::step(int steps_to_move)
153
153
// decrement the number of steps, moving one step each time:
154
154
while (steps_left > 0 )
155
155
{
156
- delayMicroseconds (this ->step_delay ); // move only if the appropriate delay has passed
156
+ unsigned long now = micros ();
157
+ // move only if the appropriate delay has passed:
158
+ if (now - this ->last_step_time >= this ->step_delay )
159
+ {
160
+ // get the timeStamp of when you stepped:
161
+ this ->last_step_time = now;
157
162
// increment or decrement the step number,
158
163
// depending on direction:
159
164
if (steps_to_move >= 0 )
@@ -174,6 +179,7 @@ void Stepper::step(int steps_to_move)
174
179
stepMotor (this ->step_number % phase_count);
175
180
// decrement the steps left:
176
181
steps_left--;
182
+ }
177
183
}
178
184
}
179
185
Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ class Stepper {
156
156
157
157
// motor pin numbers:
158
158
unsigned char motor_pin[5 ]; // Maximum 5 control signals
159
+ unsigned long last_step_time; // time stamp in us of when the last step was taken
159
160
};
160
161
161
162
#endif
You can’t perform that action at this time.
0 commit comments