libraries/PololuMotorController/pmc.cpp
// Public: Set a speed (0 to 127 for backwards, 128 to 255 for forward) based on a motor index
Set a speed (0 to 127 for backwards, 128 to 255 for forward) based on a motor index
Set a speed ( 0 to 127 for backwards 128 to 255 for forward ) based on a motor index
void MotorController::SetMotor(int motorIndex, int speed)
{
	if(speed < 0)
		speed = 0;
	else if(speed > 255)
		speed = 255;
	bool Forward;
	if(speed >= 128)
	{
		Forward = true;
		speed -= 128;
	}
	else
	{
		Forward = false;
		speed = 127 - speed;
	}
	SetMotor(motorIndex, speed, Forward);
}
void MotorController :: SetMotor ( int motorIndex , int speed ) { if ( speed < 0 ) speed = 0 ; else if ( speed > 255 ) speed = 255 ; bool Forward ; if ( speed >= 128 ) { Forward = true ; speed -= 128 ; } else { Forward = false ; speed = 127 - speed ; } SetMotor ( motorIndex , speed , Forward ) ; }
Public: Set a speed (0 to 127 for backwards, 128 to 255 for forward) based on a motor index
Public : Set a speed ( 0 to 127 for backwards 128 to 255 for forward ) based on a motor index
// Cap the given speed // Convert the given speed to directional speeds // Pass our conversion to the base SetMotor function