below is the Arduino Stepper.cpp I'm looking through, and just wondering what the "this->" is all about in front of a bunch of the variable names. Is it a naming convention or doing something I'm missing?
Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2)
{
this->step_number = 0; // which step the motor is on
this->speed = 0; // the motor speed, in revolutions per minute
this->direction = 0; // motor direction
this->last_step_time = 0; // time stamp in ms of the last step taken
this->number_of_steps = number_of_steps; // total number of steps for this motor
// Arduino pins for the motor control connection:
this->motor_pin_1 = motor_pin_1;
this->motor_pin_2 = motor_pin_2;
// setup the pins on the microcontroller:
pinMode(this->motor_pin_1, OUTPUT);
pinMode(this->motor_pin_2, OUTPUT);
// When there are only 2 pins, set the other two to 0:
this->motor_pin_3 = 0;
this->motor_pin_4 = 0;
// pin_count is used by the stepMotor() method:
this->pin_count = 2;
}
It's one way C++ allows you to access member variables (variables that are part of an object). "this" is actually a pointer to the object's current location in memory (in this case, of type Stepper*), so doing "this->(some variable)" is one way to get the value of (some variable).
If you open up the corresponding header file, probably Stepper.h, you'll see each variable that comes after the "this->" declared in the class body.