Accessories
Arduino for motors and lights library.
LocoStepper.h
Go to the documentation of this file.
1 // LocoStepper.h
2 //
40 
41 #ifndef NO_STEPPER
42 
43 #ifndef LocoStepper_h
44 #define LocoStepper_h
45 
82 {
83 public:
95  LocoStepper(uint8_t pin1, uint8_t pin2, uint8_t *inpStep2 = NULL);
107  LocoStepper(uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4, uint8_t *inpStep2 = NULL);
108 
114  void moveTo(long absolute);
115 
119  void move(long relative);
120 
125  boolean run();
126 
133  void setSpeed(float speed);
134 
137  float speed();
138 
142  long distanceToGo();
143 
147  long targetPosition();
148 
152  long currentPosition();
153 
160  void setCurrentPosition(long position);
161 
168  void disableOutputs();
169 
172  void enableOutputs();
173 
176  void setMinPulseWidth(unsigned int minWidth);
177 
178 protected:
179 
185  void step(uint8_t step);
186 
191  void step2(uint8_t step);
192 
198  void step4(uint8_t step);
199 
200 private:
204  uint8_t _pin1, _pin2, _pin3, _pin4;
205 
206  uint8_t *pSteps;
207  bool invertedDigital;
208 
210  long _currentPos; // Steps
211 
215  long _targetPos; // Steps
216 
219  float _speed; // Steps per second
220 
222  unsigned long _stepInterval;
223 
225  unsigned long _lastRunTime;
226 
228  unsigned long _lastStepTime;
229 
231  unsigned int _minPulseWidth;
232 };
233 
234 #endif
235 #endif
void step4(uint8_t step)
void disableOutputs()
void setCurrentPosition(long position)
long currentPosition()
void setMinPulseWidth(unsigned int minWidth)
long targetPosition()
long distanceToGo()
void enableOutputs()
float speed()
void setSpeed(float speed)
void step2(uint8_t step)
void step(uint8_t step)
boolean run()
Definition: LocoStepper.cpp:72
void move(long relative)
Definition: LocoStepper.cpp:63
void moveTo(long absolute)
Definition: LocoStepper.cpp:49
LocoStepper(uint8_t pin1, uint8_t pin2, uint8_t *inpStep2 = NULL)
Definition: LocoStepper.cpp:21
Support for stepper motors with acceleration etc.
Definition: LocoStepper.h:81