Skip to content

Support generic drivers for Stepper library #4257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Optimization of method initMotor()
Optimization of method initMotor() by refusing of the case switch
  • Loading branch information
skniazev committed Dec 9, 2015
commit a9278c5c9cfe860a2a6342fd02d7288167d28f34
22 changes: 5 additions & 17 deletions libraries/Stepper/src/Stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,12 @@ void Stepper::initMotor(int number_of_steps, unsigned char motor_pin_1, unsign
this->phase_count = phase_count;
// phasesMatrix is used by the stepMotor() method:
this->phasesMatrix = phasesMatrix;
this->motor_pin[0] = motor_pin_1;
this->motor_pin[1] = motor_pin_2;
this->motor_pin[2] = motor_pin_3;
this->motor_pin[3] = motor_pin_4;
this->motor_pin[4] = motor_pin_5;
for (unsigned char i = 0; i < this->pin_count; i++){
switch (i) {
case 0:
this->motor_pin[i] = motor_pin_1; // Arduino pin 1 for the motor control connection
break;
case 1:
this->motor_pin[i] = motor_pin_2; // Arduino pin 2 for the motor control connection
break;
case 2:
this->motor_pin[i] = motor_pin_3; // Arduino pin 3 for the motor control connection
break;
case 3:
this->motor_pin[i] = motor_pin_4; // Arduino pin 4 for the motor control connection
break;
case 4:
this->motor_pin[i] = motor_pin_5; // Arduino pin 5 for the motor control connection
break;
}
pinMode(this->motor_pin[i], OUTPUT); // setup the pins on the microcontroller
}
}
Expand Down