![](/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
Stepper.cpp@1:2ceb29686290, 2018-01-24 (annotated)
- Committer:
- mozillain
- Date:
- Wed Jan 24 13:10:37 2018 +0000
- Revision:
- 1:2ceb29686290
Anim
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mozillain | 1:2ceb29686290 | 1 | #include "Stepper.h" |
mozillain | 1:2ceb29686290 | 2 | #include "mbed.h" |
mozillain | 1:2ceb29686290 | 3 | |
mozillain | 1:2ceb29686290 | 4 | stepper::stepper(PinName _en, PinName _stepPin, PinName dir):en(_en), |
mozillain | 1:2ceb29686290 | 5 | stepPin(_stepPin), |
mozillain | 1:2ceb29686290 | 6 | direction(dir) |
mozillain | 1:2ceb29686290 | 7 | { |
mozillain | 1:2ceb29686290 | 8 | } |
mozillain | 1:2ceb29686290 | 9 | |
mozillain | 1:2ceb29686290 | 10 | void stepper::step(int microstep, int dir, float speed) |
mozillain | 1:2ceb29686290 | 11 | { |
mozillain | 1:2ceb29686290 | 12 | if (dir == 1) { |
mozillain | 1:2ceb29686290 | 13 | direction = 0; |
mozillain | 1:2ceb29686290 | 14 | } else if (dir == 0) { |
mozillain | 1:2ceb29686290 | 15 | direction = 1; |
mozillain | 1:2ceb29686290 | 16 | } |
mozillain | 1:2ceb29686290 | 17 | |
mozillain | 1:2ceb29686290 | 18 | stepPin = 1; |
mozillain | 1:2ceb29686290 | 19 | wait(1/speed); |
mozillain | 1:2ceb29686290 | 20 | stepPin = 0; |
mozillain | 1:2ceb29686290 | 21 | wait(1/speed); |
mozillain | 1:2ceb29686290 | 22 | } |
mozillain | 1:2ceb29686290 | 23 | |
mozillain | 1:2ceb29686290 | 24 | void stepper::enable() |
mozillain | 1:2ceb29686290 | 25 | { |
mozillain | 1:2ceb29686290 | 26 | en = 0; |
mozillain | 1:2ceb29686290 | 27 | } |
mozillain | 1:2ceb29686290 | 28 | |
mozillain | 1:2ceb29686290 | 29 | void stepper::disable() |
mozillain | 1:2ceb29686290 | 30 | { |
mozillain | 1:2ceb29686290 | 31 | en = 1; |
mozillain | 1:2ceb29686290 | 32 | } |