Class API.Motor

  • Enclosing class:
    API

    public class API.Motor
    extends java.lang.Object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void controlWithOneButton​(boolean positiveControl)
      Moves the motor forward at maximum speed if the button is pressed.
      void controlWithOneButton​(boolean positiveControl, double speed)
      Moves the motor forward at the provided speed if the button is pressed.
      void controlWithTwoButtons​(boolean positiveControl, boolean negativeControl)
      Moves the motor forward or backward at maximum speed based on the button inputs
      void controlWithTwoButtons​(boolean positiveControl, boolean negativeControl, double speed)
      Moves the motor forward or backward at the provided speed based on the button inputs
      double getPower()
      Gets the previously set power
      double getRawPower()
      Gets the power the motor is currently moving at, or 0 if not moving
      void resetEncoder()
      Stops and resets the encoder
      void setBehaviour​(API.MotorBehaviour behaviour)
      Set the zero-power behaviour of the motor.
      void setDirection​(API.Direction direction)
      Sets the direction the motor should move in, without starting the motor
      void setDirection​(API.Direction direction, boolean immediate)
      Sets the direction the motor should move in
      void setPower​(double power)
      Sets the power without starting the motor
      void start()
      Starts the motor with the previously set power
      void start​(double power)
      Starts the motor with the specified power
      void stop()
      Stops the motor
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • start

        public void start()
        Starts the motor with the previously set power
      • start

        public void start​(double power)
        Starts the motor with the specified power
        Parameters:
        power - the power to use for the motor
      • stop

        public void stop()
        Stops the motor
      • setPower

        public void setPower​(double power)
        Sets the power without starting the motor
        Parameters:
        power - the power to use for the motor
      • getPower

        public double getPower()
        Gets the previously set power
        Returns:
        the power
      • getRawPower

        public double getRawPower()
        Gets the power the motor is currently moving at, or 0 if not moving
        Returns:
        the power
      • setDirection

        public void setDirection​(API.Direction direction)
        Sets the direction the motor should move in, without starting the motor
        Parameters:
        direction - the direction to use for the motor
      • setDirection

        public void setDirection​(API.Direction direction,
                                 boolean immediate)
        Sets the direction the motor should move in
        Parameters:
        direction - the direction to use for the motor
        immediate - whether to immediately start the motor with the new direction
      • resetEncoder

        public void resetEncoder()
        Stops and resets the encoder
      • setBehaviour

        public void setBehaviour​(API.MotorBehaviour behaviour)
        Set the zero-power behaviour of the motor. BRAKE means to immediately apply brakes when power is 0, and FLOAT means to come to a rolling stop.
        Parameters:
        behaviour - the behaviour to use
      • controlWithTwoButtons

        public void controlWithTwoButtons​(boolean positiveControl,
                                          boolean negativeControl,
                                          double speed)
        Moves the motor forward or backward at the provided speed based on the button inputs
        Parameters:
        positiveControl - the button used to move the motor forward
        negativeControl - the button used to move the motor backward
      • controlWithTwoButtons

        public void controlWithTwoButtons​(boolean positiveControl,
                                          boolean negativeControl)
        Moves the motor forward or backward at maximum speed based on the button inputs
        Parameters:
        positiveControl - the button used to move the motor forward
        negativeControl - the button used to move the motor backward
      • controlWithOneButton

        public void controlWithOneButton​(boolean positiveControl,
                                         double speed)
        Moves the motor forward at the provided speed if the button is pressed.
        Parameters:
        positiveControl - the button used to move forward
      • controlWithOneButton

        public void controlWithOneButton​(boolean positiveControl)
        Moves the motor forward at maximum speed if the button is pressed.
        Parameters:
        positiveControl - the button used to move forward