コード例 #1
0
 /*
  * handleBattery
  *
  * The Matrix controller has a separate battery whose voltage can be read.
  */
 protected void handleBattery() {
   if ((firstBattery) || (spamPrevention.time() > SPAM_PREVENTION_FREQ)) {
     battery = mc.getBattery();
     spamPrevention.reset();
     firstBattery = false;
   }
   telemetry.addData("Battery: ", ((float) battery / 1000));
 }
コード例 #2
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;
    }
  }