update
Diff: Stepper.h
- Revision:
- 1:a456aa3935ca
- Parent:
- 0:f2a3b0be279d
--- a/Stepper.h Mon Apr 15 11:29:15 2013 +0000 +++ b/Stepper.h Mon Sep 22 14:18:31 2014 +0000 @@ -34,9 +34,9 @@ * } * @endcode */ -class Stepper +class Stepper : public TimerEvent { -public: +public: /** Create Stepper instance connected to pin clk & dir * @param clk pin to connect at clk/step output * @param dir pin to connect at dir output @@ -112,21 +112,24 @@ typedef enum {CW=1,CCW=0} direction; protected: - void run(void); //step generator thread unsigned int nTo(float speed,float acc); - + private: - float _acc; //Acceleration [step/s²] - float _dec; //Decceleration [step/s²] - float _spd; //Speed [step/s] - unsigned int _steps; //nbr total of steps per mov - DigitalOut _clk; //output clock pin - DigitalOut _dir; //output dir pin - Timeout _timer; //step timer + float _acc; //Acceleration [step/s²] + float _dec; //Decceleration [step/s²] + float _spd; //Speed [step/s] + unsigned int _steps; //nbr total of steps per mov + DigitalOut _clk; //output clock pin + DigitalOut _dir; //output dir pin enum {STOP,ACCEL,CRUISE,DECEL}_state; //Motor state - unsigned int _dt0; //initial delay [µs] - unsigned int _dtmin; //delay minimum [µs] - int _pos; //motor position + unsigned int _dt0; //initial delay [µs] + unsigned int _dtmin; //delay minimum [µs] + unsigned int _dtn; //current delay + int _pos; //motor position + unsigned int _n; //steps counters + unsigned int _nStartDec; //steps to decelerate + virtual void handler(); + }; #endif \ No newline at end of file