|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.wpi.first.wpilibj.buttons.Button
public abstract class Button
This class provides an easy way to link commands to inputs.
It is very easy to link a button to a command. For instance, you could
link the trigger button of a joystick to a "score" command.
It is encouraged that teams write a subclass of Button if they want to have
something unusual (for instance, if they want to react to the user holding
a button while the robot is reading a certain sensor input). For this, they
only have to write the get()
method to get the full functionality
of the Button class.
Nested Class Summary | |
---|---|
class |
Button.ButtonScheduler
An internal class of Button . |
Constructor Summary | |
---|---|
Button()
|
Method Summary | |
---|---|
abstract boolean |
get()
Returns whether or not the button is pressed. |
NetworkTable |
getTable()
Returns the NetworkTable associated with the data. |
java.lang.String |
getType()
Returns the type of the data. |
void |
whenPressed(Command command)
Starts the given command whenever the button is newly pressed. |
void |
whenReleased(Command command)
Starts the command when the button is released |
void |
whileHeld(Command command)
Constantly starts the given command while the button is held. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Button()
Method Detail |
---|
public abstract boolean get()
public void whenPressed(Command command)
command
- the command to startpublic void whileHeld(Command command)
Command.start()
will be called repeatedly while the button is held,
and will be canceled when the button is released.
command
- the command to startpublic void whenReleased(Command command)
command
- the command to startpublic java.lang.String getType()
SmartDashboardData
getTable()
.
For instance, if the type was "Button", then the SmartDashboard would show the data
as a button on the desktop and would know to look at and modify the "pressed" field in the
NetworkTable
returned by getTable()
.
getType
in interface SmartDashboardData
public NetworkTable getTable()
SmartDashboardData
NetworkTable
associated with the data.
The table should contain all the information the desktop version of SmartDashboard needs
to interact with the object. The data should both keep the table up-to-date and also react
to changes that the SmartDashboard might make.
For instance, the SendablePIDController
will put its p, i and d values into its table
and will change them if the table receives new values.
This method should return the same table between calls
getTable
in interface SmartDashboardData
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |