Package org.firstinspires.ftc.teamcode
Class API.Motor
- java.lang.Object
-
- org.firstinspires.ftc.teamcode.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 inputsvoid
controlWithTwoButtons(boolean positiveControl, boolean negativeControl, double speed)
Moves the motor forward or backward at the provided speed based on the button inputsdouble
getPower()
Gets the previously set powerdouble
getRawPower()
Gets the power the motor is currently moving at, or 0 if not movingvoid
resetEncoder()
Stops and resets the encodervoid
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 motorvoid
setDirection(API.Direction direction, boolean immediate)
Sets the direction the motor should move invoid
setPower(double power)
Sets the power without starting the motorvoid
start()
Starts the motor with the previously set powervoid
start(double power)
Starts the motor with the specified powervoid
stop()
Stops the motor
-
-
-
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 motorimmediate
- 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 forwardnegativeControl
- 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 forwardnegativeControl
- 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
-
-