![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Anim
Dependencies: BSP_DISCO_F429ZI EEPROM_DISCO_F429ZI FT810 GYRO_DISCO_F429ZI KEYPAD_DISCO_F429ZI LCD_DISCO_F429ZI PinDetect SDRAM_DISCO_F429ZI TS_DISCO_F429ZI mbed
Diff: Stepper.cpp
- Revision:
- 1:2ceb29686290
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Stepper.cpp Wed Jan 24 13:10:37 2018 +0000 @@ -0,0 +1,32 @@ +#include "Stepper.h" +#include "mbed.h" + +stepper::stepper(PinName _en, PinName _stepPin, PinName dir):en(_en), + stepPin(_stepPin), + direction(dir) +{ +} + +void stepper::step(int microstep, int dir, float speed) +{ + if (dir == 1) { + direction = 0; + } else if (dir == 0) { + direction = 1; + } + + stepPin = 1; + wait(1/speed); + stepPin = 0; + wait(1/speed); +} + +void stepper::enable() +{ + en = 0; +} + +void stepper::disable() +{ + en = 1; +} \ No newline at end of file