java.lang.Object
io.github.roboblazers7617.buttonbox.Control
io.github.roboblazers7617.buttonbox.controls.Button
Direct Known Subclasses:
PhysicalButton

public class Button extends Control
A push button with configurable feedback. Intended for use with a momentary switch that is lit by a controllable LED.
  • Constructor Details

    • Button

      public Button(String id)
      Creates a new Button.
      Parameters:
      id - The ID string for the Button to use.
      See Also:
  • Method Details

    • setupSimulation

      public void setupSimulation()
      Description copied from class: Control
      Should set up any simulation-specific things.

      Called as a part of the constructor if the library is running in simulation.

      Overrides:
      setupSimulation in class Control
    • updateServer

      public void updateServer()
      Description copied from class: Control
      Updates the control's state on the server.

      This doesn't do anything by default, and should be overridden by the class inheritting this.

      Overrides:
      updateServer in class Control
    • updateClient

      public void updateClient()
      Description copied from class: Control
      Updates the control's state on the client. This should get any feedback from the server, but this should not interface with the buttonbox hardware.

      This doesn't do anything by default, and should be overridden by the class inheritting this.

      Overrides:
      updateClient in class Control
    • setupNetworkTables

      public void setupNetworkTables(NetworkTable table)
      Description copied from class: Control
      Called by the Control class when the NetworkTable is set by Control.setTable(NetworkTable). intended to be called outside of the class.

      This should create all of the NetworkTables publishers and subscribers for the inheritting class.

      Overrides:
      setupNetworkTables in class Control
      Parameters:
      table - The table to use. When called by Control.setTable(NetworkTable), this is a subtable with the ID string as its key.
    • getState

      public boolean getState()
      Gets the button's state.
      Returns:
      Button state (true = pushed, false = released).
    • setPressed

      public void setPressed(boolean pressed)
      Sets whether the button is pressed or not. Published to NetworkTables immediately.
      Parameters:
      pressed - Is the button pressed?
    • getTrigger

      public Trigger getTrigger()
      Get a trigger for the button.
      Returns:
      Trigger.
    • setMode

      public Button setMode(Button.ButtonMode buttonMode)
      Sets the button's mode.
      Parameters:
      buttonMode - Mode to set the button to.
      Returns:
      The modified object for method chaining.