-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from DCC-EX:next-release
v0.7.0-Devel
- Loading branch information
Showing
14 changed files
with
560 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
/// The latest version of this documentation can be downloaded from | ||
/// http://www.airspayce.com/mikem/arduino/AccelStepper | ||
/// The version of the package that this documentation refers to can be downloaded | ||
/// from http://www.airspayce.com/mikem/arduino/AccelStepper/AccelStepper-1.61.zip | ||
/// from http://www.airspayce.com/mikem/arduino/AccelStepper/AccelStepper-1.64.zip | ||
/// | ||
/// Example Arduino programs are included to show the main modes of use. | ||
/// | ||
|
@@ -35,6 +35,10 @@ | |
/// - http://www.catb.org/esr/faqs/smart-questions.html | ||
/// - http://www.chiark.greenend.org.uk/~shgtatham/bugs.html | ||
/// | ||
/// Beginners to C++ and stepper motors in general may find this helpful: | ||
/// - https://hackaday.io/project/183279-accelstepper-the-missing-manual | ||
/// - https://hackaday.io/project/183713-using-the-arduino-accelstepper-library | ||
/// | ||
/// Tested on Arduino Diecimila and Mega with arduino-0018 & arduino-0021 | ||
/// on OpenSuSE 11.1 and avr-libc-1.6.1-1.15, | ||
/// cross-avr-binutils-2.19-9.1, cross-avr-gcc-4.1.3_20080612-26.5. | ||
|
@@ -81,7 +85,7 @@ | |
/// | ||
/// \par Copyright | ||
/// | ||
/// This software is Copyright (C) 2010-2018 Mike McCauley. Use is subject to license | ||
/// This software is Copyright (C) 2010-2021 Mike McCauley. Use is subject to license | ||
/// conditions. The main licensing options available are GPL V3 or Commercial: | ||
/// | ||
/// \par Open Source Licensing GPL V3 | ||
|
@@ -249,9 +253,18 @@ | |
/// \version 1.61 2020-04-20 | ||
/// Added yield() call in runToPosition(), so that platforms like esp8266 dont hang/crash | ||
/// during long runs. | ||
/// \version 1.62 2022-05-22 | ||
/// Added link to AccelStepper - The Missing Manual.<br> | ||
/// Fixed a problem when setting the maxSpeed to 1.0 due to incomplete initialisation. | ||
/// Reported by Olivier Pécheux. <br> | ||
/// \version 1.63 2022-06-30 | ||
/// Added virtual destructor at the request of Jan.<br> | ||
/// \version 1.64 2022-10-31 | ||
/// Patch courtesy acwest: Changes to make AccelStepper more subclassable. These changes are | ||
/// largely oriented to implementing new step-scheduling algorithms. | ||
/// | ||
/// \author Mike McCauley ([email protected]) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS | ||
// Copyright (C) 2009-2013 Mike McCauley | ||
/// \author Mike McCauley ([email protected]) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE GOOGLE GROUP | ||
// Copyright (C) 2009-2020 Mike McCauley | ||
// $Id: AccelStepper.h,v 1.28 2020/04/20 00:15:03 mikem Exp mikem $ | ||
|
||
#ifndef AccelStepper_h | ||
|
@@ -370,12 +383,7 @@ class AccelStepper | |
/// to pin 5. | ||
/// \param[in] enable If this is true (the default), enableOutputs() will be called to enable | ||
/// the output pins at construction time. | ||
|
||
// Line below commented out is the original AccelStepper line. | ||
// AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true); | ||
|
||
// EX-Turntable modification: add extra flag to enable automatic inversion of two wire drivers at instantiation. | ||
AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true, bool invert = false); | ||
AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true); | ||
|
||
/// Alternate Constructor which will call your own functions for forward and backward steps. | ||
/// You can have multiple simultaneous steppers, all moving | ||
|
@@ -434,6 +442,11 @@ class AccelStepper | |
/// root to be calculated. Dont call more ofthen than needed | ||
void setAcceleration(float acceleration); | ||
|
||
/// Returns the acceleration/deceleration rate configured for this stepper | ||
/// that was previously set by setAcceleration(); | ||
/// \return The currently configured acceleration/deceleration | ||
float acceleration(); | ||
|
||
/// Sets the desired constant speed for use with runSpeed(). | ||
/// \param[in] speed The desired constant speed in steps per | ||
/// second. Positive is clockwise. Speeds of more than 1000 steps per | ||
|
@@ -476,7 +489,10 @@ class AccelStepper | |
/// position. Dont use this in event loops, since it blocks. | ||
void runToPosition(); | ||
|
||
/// Runs at the currently selected speed until the target position is reached. | ||
/// Executes runSpeed() unless the targetPosition is reached. | ||
/// This function needs to be called often just like runSpeed() or run(). | ||
/// Will step the motor if a step is required at the currently selected | ||
/// speed unless the target position has been reached. | ||
/// Does not implement accelerations. | ||
/// \return true if it stepped | ||
boolean runSpeedToPosition(); | ||
|
@@ -538,6 +554,8 @@ class AccelStepper | |
/// \return true if the speed is not zero or not at the target position | ||
bool isRunning(); | ||
|
||
/// Virtual destructor to prevent warnings during delete | ||
virtual ~AccelStepper() {}; | ||
protected: | ||
|
||
/// \brief Direction indicator | ||
|
@@ -556,7 +574,8 @@ class AccelStepper | |
/// \li after change to acceleration through setAcceleration() | ||
/// \li after change to target position (relative or absolute) through | ||
/// move() or moveTo() | ||
void computeNewSpeed(); | ||
/// \return the new step interval | ||
virtual unsigned long computeNewSpeed(); | ||
|
||
/// Low level function to set the motor output pins | ||
/// bit 0 of the mask corresponds to _pin[0] | ||
|
@@ -571,6 +590,16 @@ class AccelStepper | |
/// number of pins defined for the stepper. | ||
/// \param[in] step The current step phase number (0 to 7) | ||
virtual void step(long step); | ||
|
||
/// Called to execute a clockwise(+) step. Only called when a new step is | ||
/// required. This increments the _currentPos and calls step() | ||
/// \return the updated current position | ||
long stepForward(); | ||
|
||
/// Called to execute a counter-clockwise(-) step. Only called when a new step is | ||
/// required. This decrements the _currentPos and calls step() | ||
/// \return the updated current position | ||
long stepBackward(); | ||
|
||
/// Called to execute a step using stepper functions (pins = 0) Only called when a new step is | ||
/// required. Calls _forward() or _backward() to perform the step | ||
|
@@ -612,7 +641,7 @@ class AccelStepper | |
/// \param[in] step The current step phase number (0 to 7) | ||
virtual void step6(long step); | ||
|
||
/// Called to execute a step on a 4 pin half-steper motor. Only called when a new step is | ||
/// Called to execute a step on a 4 pin half-stepper motor. Only called when a new step is | ||
/// required. Subclasses may override to implement new stepping | ||
/// interfaces. The default sets or clears the outputs of pin1, pin2, | ||
/// pin3, pin4. | ||
|
@@ -623,6 +652,10 @@ class AccelStepper | |
/// Protected because some peoples subclasses need it to be so | ||
boolean _direction; // 1 == CW | ||
|
||
/// The current interval between steps in microseconds. | ||
/// 0 means the motor is currently stopped with _speed == 0 | ||
unsigned long _stepInterval; | ||
|
||
private: | ||
/// Number of pins on the stepper motor. Permits 2 or 4. 2 pins is a | ||
/// bipolar, and 4 pins is a unipolar. | ||
|
@@ -655,10 +688,6 @@ class AccelStepper | |
float _acceleration; | ||
float _sqrt_twoa; // Precomputed sqrt(2*_acceleration) | ||
|
||
/// The current interval between steps in microseconds. | ||
/// 0 means the motor is currently stopped with _speed == 0 | ||
unsigned long _stepInterval; | ||
|
||
/// The last step time in microseconds | ||
unsigned long _lastStepTime; | ||
|
||
|
@@ -695,9 +724,6 @@ class AccelStepper | |
/// Min step size in microseconds based on maxSpeed | ||
float _cmin; // at max speed | ||
|
||
// EX-Turntable modification: add extra flag to enable automatic inversion of two wire drivers at instantiation. | ||
bool _invert; | ||
|
||
}; | ||
|
||
/// @example Random.pde | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.