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.
Fork of MotorLib by
Diff: motor.cpp
- Revision:
- 6:aec892eb1b49
- Parent:
- 4:c009bcd5518c
- Child:
- 7:439458133bba
diff -r 9886fd337a4b -r aec892eb1b49 motor.cpp
--- a/motor.cpp Wed Oct 05 18:54:35 2016 +0000
+++ b/motor.cpp Tue Oct 11 22:21:56 2016 +0000
@@ -43,6 +43,12 @@
SetCommand(MOTOR_zero);
}
+void Motor::RunInfinite(MotorDir dir) {
+ SetDirection( dir);
+ NumSteps = -1;
+ SetCommand(MOTOR_start);
+}
+
void Motor::RunSteps(MotorDir dir, uint32_t steps) {
SetDirection( dir);
NumSteps = steps;
@@ -123,7 +129,7 @@
}
else if (state==Motor_RUN) {
// Action always performed in that state
- if (NumSteps>0) {
+ if (NumSteps>0 || NumSteps <0) {
RunMotor();
NumSteps--;
}
