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 StepperController by
Diff: steppercontroller.cpp
- Revision:
- 1:6e8186dd5bfa
- Parent:
- 0:2cfd64d210f3
- Child:
- 2:d589fc047bc9
--- a/steppercontroller.cpp Mon Jun 29 07:47:45 2015 +0000 +++ b/steppercontroller.cpp Fri Jun 08 08:05:29 2018 +0000 @@ -1,4 +1,3 @@ - #include "steppercontroller.h" StepperController::StepperController(PinName phaseA,PinName enA, PinName phaseB, PinName enB ): @@ -32,6 +31,11 @@ this->dir = dir; } +void StepperController::setSequenceType(SequenceType seq) +{ + this->seq = seq; +} + void StepperController::updateOutputs() { switch(state){ @@ -42,24 +46,44 @@ enB = 0.0f; break; case 1: - phaseA = 0; - enA = pulseWidth; - phaseB = 0; - enB = 0.0f; + switch(seq) { + case Consecutive: + phaseA = 0; + enA = pulseWidth; + phaseB = 0; + enB = 0.0f; + break; + case Interleaved: + phaseA = 0; + enA = 0.0f; + phaseB = 1; + enB = pulseWidth; + break; + } break; case 2: - phaseA = 0; - enA = 0.0f; - phaseB = 1; - enB = pulseWidth; + switch(seq) { + case Consecutive: + phaseA = 0; + enA = 0.0f; + phaseB = 1; + enB = pulseWidth; + break; + case Interleaved: + phaseA = 0; + enA = pulseWidth; + phaseB = 0; + enB = 0.0f; + break; + } break; case 3: - phaseA = 0; - enA = 0.0f; - phaseB = 0; - enB = pulseWidth; + phaseA = 0; + enA = 0.0f; + phaseB = 0; + enB = pulseWidth; break; default: @@ -68,10 +92,4 @@ phaseB = 0; enB = 0.0; } -} - - - - - - \ No newline at end of file +} \ No newline at end of file