src/Train.cpp
/**
 * setSpeed sets the target speed. The train will slowly
 * accelerate or slow down to the requested speed based
 * on the set acceleration parameters.
 */
setSpeed sets the target speed. The train will slowly
accelerate or slow down to the requested speed based
on the set acceleration parameters.
setSpeed sets the target speed . The train will slowly accelerate or slow down to the requested speed based on the set acceleration parameters .
void Train::setSpeed(int16_t speed) {
  if (speed < 0) {
    this->targetDirection = BACKWARD;
  } else {
    this->targetDirection = FORWARD;
  }
  if (this->targetDirection != this->currentDirection) {
    this->isChangingDirection = true;
  }
  this->targetSpeed = abs(speed);
}
void Train :: setSpeed ( int16_t speed ) { if ( speed < 0 ) { this -> targetDirection = BACKWARD ; } else { this -> targetDirection = FORWARD ; } if ( this -> targetDirection != this -> currentDirection ) { this -> isChangingDirection = true ; } this -> targetSpeed = abs ( speed ) ; }
setSpeed sets the target speed.
setSpeed sets the target speed .