Package com.revrobotics
Class CANDigitalInput
- java.lang.Object
-
- com.revrobotics.CANDigitalInput
-
public class CANDigitalInput extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CANDigitalInput.LimitSwitch
static class
CANDigitalInput.LimitSwitchPolarity
-
Constructor Summary
Constructors Constructor Description CANDigitalInput(CANSparkMax device, CANDigitalInput.LimitSwitch limitSwitch, CANDigitalInput.LimitSwitchPolarity polarity)
Constructs a CANDigitalInput.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CANError
enableLimitSwitch(boolean enable)
Enables or disables controller shutdown based on limit switch.boolean
get()
Get the value from a digital input channel.boolean
isLimitSwitchEnabled()
-
-
-
Constructor Detail
-
CANDigitalInput
public CANDigitalInput(CANSparkMax device, CANDigitalInput.LimitSwitch limitSwitch, CANDigitalInput.LimitSwitchPolarity polarity)
Constructs a CANDigitalInput.- Parameters:
device
- The Spark Max to which the limit switch is attached.limitSwitch
- Whether this is forward or reverse limit switch.polarity
- Whether the limit switch is normally open or normally closed.
-
-
Method Detail
-
get
public boolean get()
Get the value from a digital input channel. Retrieve the value of a single digital input channel from a motor controller. This method will return the state of the limit input based on the selected polarity, whether or not it is enabled.- Returns:
- The state of the limit switch based on the configured polarity
-
enableLimitSwitch
public CANError enableLimitSwitch(boolean enable)
Enables or disables controller shutdown based on limit switch.- Parameters:
enable
- Enable/disable motor shutdown based on limit switch state. This does not effect the result of the get() command.- Returns:
- CANError Set to CANError::kOk if successful
-
isLimitSwitchEnabled
public boolean isLimitSwitchEnabled()
- Returns:
- True if limit switch is enabled
-
-