コード例 #1
0
  /*
   * handleMotors
   *
   * Oscillate the motors.
   */
  protected void handleMotors() {
    if ((firstMotors) || (motorOscTimer.time() > MOTOR_OSC_FREQ)) {
      motorPower = -motorPower;

      /*
       * The MatrixDcMotorController's setMotorPower() method may take
       * a collection of motors.  If this is chosen, then the controller will
       * set a pending bit.  The pending bit tells the controller to
       * defer turning on, or changing the current set point, for a motor
       * until the pending bit is cleared.
       *
       * When the pending bit is cleared all motor power values are applied
       * simultaneously.  setMotorPower() handles the pending bit for you.
       */
      mc.setMotorPower(motorSet, motorPower);
      motorOscTimer.reset();
      firstMotors = false;
    }
  }