Class DigitalInput

java.lang.Object
org.wpilib.hardware.discrete.DigitalInput
All Implemented Interfaces:
AutoCloseable, TelemetryLoggable

public class DigitalInput extends Object implements AutoCloseable, TelemetryLoggable
Class to read a digital input. This class will read digital inputs and return the current value on the channel. Other devices such as encoders, gear tooth sensors, etc. that are implemented elsewhere will automatically allocate digital inputs and outputs as required. This class is only for devices like switches etc. that aren't implemented anywhere else.
  • Constructor Details

    • DigitalInput

      public DigitalInput(int channel)
      Create an instance of a Digital Input class. Creates a digital input given a channel.
      Parameters:
      channel - the SmartIO channel for the digital input
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • get

      public boolean get()
      Get the value from a digital input channel. Retrieve the value of a single digital input channel from the FPGA.
      Returns:
      the status of the digital input
    • getChannel

      public int getChannel()
      Get the channel of the digital input.
      Returns:
      The GPIO channel number that this object represents.
    • setSimDevice

      public void setSimDevice(SimDevice device)
      Indicates this input is used by a simulated device.
      Parameters:
      device - simulated device handle
    • logTo

      public void logTo(TelemetryTable table)
      Description copied from interface: TelemetryLoggable
      Logs the object to a TelemetryTable.
      Specified by:
      logTo in interface TelemetryLoggable
      Parameters:
      table - telemetry table
    • getTelemetryType

      public String getTelemetryType()
      Description copied from interface: TelemetryLoggable
      Gets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.
      Specified by:
      getTelemetryType in interface TelemetryLoggable
      Returns:
      Table type