My Version of the Crealab MotorLib.
Fork of MotorLib by
Revision 6:aec892eb1b49, committed 2016-10-11
- Comitter:
- garphil
- Date:
- Tue Oct 11 22:21:56 2016 +0000
- Parent:
- 5:9886fd337a4b
- Child:
- 7:439458133bba
- Commit message:
- Added Infinite Run;
Changed in this revision
motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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--; }
--- a/motor.h Wed Oct 05 18:54:35 2016 +0000 +++ b/motor.h Tue Oct 11 22:21:56 2016 +0000 @@ -40,6 +40,7 @@ Motor(PinName _MPh0, PinName _MPh1, PinName _MPh2, PinName _MPh3, uint32_t TickTime); void RunSteps(MotorDir direction, uint32_t steps); void RunDegrees(MotorDir direction, float steps); + void RunInfinite(MotorDir direction); void SetDirection(MotorDir dir); void TestMotor(); void RunMotor();