Package edu.wpi.first.wpilibj
Class DigitalInput
- java.lang.Object
-
- edu.wpi.first.wpilibj.InterruptableSensorBase
-
- edu.wpi.first.wpilibj.DigitalSource
-
- edu.wpi.first.wpilibj.DigitalInput
-
- All Implemented Interfaces:
Sendable,AutoCloseable
public class DigitalInput extends DigitalSource implements Sendable, AutoCloseable
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
InterruptableSensorBase.WaitResult
-
-
Field Summary
-
Fields inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
m_interrupt, m_isSynchronousInterrupt
-
-
Constructor Summary
Constructors Constructor Description DigitalInput(int channel)Create an instance of a Digital Input class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanget()Get the value from a digital input channel.intgetAnalogTriggerTypeForRouting()Get the analog trigger type.intgetChannel()Get the channel of the digital input.intgetPortHandleForRouting()Get the HAL Port Handle.voidinitSendable(SendableBuilder builder)Initializes thisSendableobject.booleanisAnalogTrigger()Is this an analog trigger.voidsetSimDevice(SimDevice device)Indicates this input is used by a simulated device.-
Methods inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
allocateInterrupts, cancelInterrupts, disableInterrupts, enableInterrupts, readFallingTimestamp, readRisingTimestamp, requestInterrupts, requestInterrupts, requestInterrupts, setUpSourceEdge, waitForInterrupt, waitForInterrupt
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.wpilibj.Sendable
addChild, getName, getSubsystem, setName, setName, setName, setName, setSubsystem
-
-
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classInterruptableSensorBase
-
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.- Specified by:
getChannelin classDigitalSource- Returns:
- The GPIO channel number that this object represents.
-
getAnalogTriggerTypeForRouting
public int getAnalogTriggerTypeForRouting()
Get the analog trigger type.- Specified by:
getAnalogTriggerTypeForRoutingin classInterruptableSensorBase- Returns:
- false
-
isAnalogTrigger
public boolean isAnalogTrigger()
Is this an analog trigger.- Specified by:
isAnalogTriggerin classDigitalSource- Returns:
- true if this is an analog trigger
-
getPortHandleForRouting
public int getPortHandleForRouting()
Get the HAL Port Handle.- Specified by:
getPortHandleForRoutingin classInterruptableSensorBase- Returns:
- The HAL Handle to the specified source.
-
setSimDevice
public void setSimDevice(SimDevice device)
Indicates this input is used by a simulated device.- Parameters:
device- simulated device handle
-
initSendable
public void initSendable(SendableBuilder builder)
Description copied from interface:SendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceSendable- Parameters:
builder- sendable builder
-
-