ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
Diff: StepperMotor/Stepper.h
- Revision:
- 92:f09f55aa992b
- Child:
- 93:c0b040954eac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/StepperMotor/Stepper.h Fri May 06 15:25:21 2016 +0000 @@ -0,0 +1,39 @@ +#ifndef MBED_STEPPER_H +#define MBED_STEPPER_H + +#include "mbed.h" + +class Stepper +{ +public: + Stepper(PinName _en, PinName _stepPin, PinName dir, PinName _minEndStop, float step_per_mm); + bool step(int _number, int _dir, float _speed, bool _async=false); + bool mm(int _number, int _dir, bool _async=false); + bool mm(float _distance, bool _async=false); + + bool done(); + + void enable(); + void disable(); + + int getEndStop() {return minEndStop.read();} + + void tick(); + + float Step_Per_MM; +private: + DigitalOut en; + DigitalOut stepPin; + DigitalOut direction; + DigitalIn minEndStop; + + int number; + int dir; + float speed; + bool async; + Ticker ticker; + +}; + + +#endif \ No newline at end of file