Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Stepper.cpp
- Committer:
- stretch
- Date:
- 2012-04-28
- Revision:
- 0:3058939fa37c
File content as of revision 0:3058939fa37c:
#include "Stepper.h"
Stepper::Stepper(PinName step, PinName dir, PinName en) : _step(step), _dir(dir), _en(en) {
_step = 0, _dir = 0, _en = 1;
_position = 0;
}
void Stepper::stepOn(bool direction) {
_dir = direction;
if (direction) {
_position++;
} else {
_position--;
}
_step = 1;
}
void Stepper::stepOff(void) {
_step = 0;
}
void Stepper::enable(bool en) {
_en = !en;
}
void Stepper::setPosition(long position) {
_position = position;
}
long Stepper::getPosition(void) {
return _position;
}