edu.wpi.first.wpilibj
Class DigitalInput

java.lang.Object
  extended by edu.wpi.first.wpilibj.SensorBase
      extended by edu.wpi.first.wpilibj.InterruptableSensorBase
          extended by edu.wpi.first.wpilibj.DigitalSource
              extended by edu.wpi.first.wpilibj.DigitalInput
All Implemented Interfaces:
IDevice, IInputOutput, FrcBotSimComponent

public class DigitalInput
extends DigitalSource
implements IInputOutput

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.


Field Summary
 
Fields inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
interrupts, m_interrupt, m_interruptIndex, m_manager
 
Fields inherited from class edu.wpi.first.wpilibj.SensorBase
kAnalogChannels, kAnalogModules, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond, n_simProperties
 
Constructor Summary
DigitalInput(int channel)
          Create an instance of a Digital Input class.
DigitalInput(int moduleNumber, int channel)
          Create an instance of a Digital Input class.
 
Method Summary
 void free()
          Free the resources used by this object
 boolean get()
          Get the value from a digital input channel.
 boolean getAnalogTriggerForRouting()
          Is this an analog trigger
 int getChannel()
          Get the channel of the digital input
 int getChannelForRouting()
          Get the channel routing number
 int getModuleForRouting()
          Get the module routing number
 void requestInterrupts()
          Request interrupts synchronously on this digital input.
 void requestInterrupts(java.lang.Object handler, java.lang.Object param)
          Request interrupts asynchronously on this digital input.
 void setUpSourceEdge(boolean risingEdge, boolean fallingEdge)
          Set which edge to trigger interrupts on
 
Methods inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
allocateInterrupts, cancelInterrupts, disableInterrupts, enableInterrupts, readInterruptTimestamp, waitForInterrupt
 
Methods inherited from class edu.wpi.first.wpilibj.SensorBase
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, getSimProperties, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigitalInput

public DigitalInput(int channel)
Create an instance of a Digital Input class. Creates a digital input given a channel and uses the default module.

Parameters:
channel - the port for the digital input

DigitalInput

public DigitalInput(int moduleNumber,
                    int channel)
Create an instance of a Digital Input class. Creates a digital input given an channel and module.

Parameters:
moduleNumber - The number of the digital module to use for this input
channel - the port for the digital input
Method Detail

free

public void free()
Description copied from class: SensorBase
Free the resources used by this object

Overrides:
free in class SensorBase

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 stats of the digital input

getChannel

public int getChannel()
Get the channel of the digital input

Returns:
The GPIO channel number that this object represents.

getChannelForRouting

public int getChannelForRouting()
Description copied from class: DigitalSource
Get the channel routing number

Specified by:
getChannelForRouting in class DigitalSource
Returns:
channel routing number

getModuleForRouting

public int getModuleForRouting()
Description copied from class: DigitalSource
Get the module routing number

Specified by:
getModuleForRouting in class DigitalSource
Returns:
module routing number

getAnalogTriggerForRouting

public boolean getAnalogTriggerForRouting()
Description copied from class: DigitalSource
Is this an analog trigger

Specified by:
getAnalogTriggerForRouting in class DigitalSource
Returns:
true if this is an analog trigger

requestInterrupts

public void requestInterrupts(java.lang.Object handler,
                              java.lang.Object param)
Request interrupts asynchronously on this digital input.

Parameters:
handler - The address of the interrupt handler function of type tInterruptHandler that will be called whenever there is an interrupt on the digitial input port. Request interrupts in synchronus mode where the user program interrupt handler will be called when an interrupt occurs. The default is interrupt on rising edges only.
param - argument to pass to the handler

requestInterrupts

public void requestInterrupts()
Request interrupts synchronously on this digital input. Request interrupts in synchronus mode where the user program will have to explicitly wait for the interrupt to occur. The default is interrupt on rising edges only.


setUpSourceEdge

public void setUpSourceEdge(boolean risingEdge,
                            boolean fallingEdge)
Set which edge to trigger interrupts on

Parameters:
risingEdge - true to interrupt on rising edge
fallingEdge - true to interrupt on falling edge