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.
Diff: Stepper.cpp
- Revision:
- 0:3058939fa37c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Stepper.cpp Sat Apr 28 21:08:58 2012 +0000
@@ -0,0 +1,32 @@
+#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;
+}
\ No newline at end of file